Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Richard Thompson 13 posts 93 karma points
    Nov 09, 2022 @ 11:00
    Richard Thompson
    0

    Media names when a file is copied into the media folder

    Please, does anybody here, or Umbraco know what formulae they use to generate the media name. Yes, dashes are replaced with spaces etc. But then some words are capitalised and yet some are not?

    I need to replicate how the media name is generated.

    Thanks Rich

  • Richard Thompson 13 posts 93 karma points
    Mar 10, 2023 @ 08:34
    Richard Thompson
    0

    Anyone out there in Umbraco Master land got any hints on this:

    Please, does anybody here, or Umbraco know what formulae they use to generate the media name. Yes, dashes are replaced with spaces etc. But then some words are capitalised and yet some are not?

    I need to replicate how the media name is generated.

    Thanks Rich

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Mar 10, 2023 @ 08:53
    Huw Reddick
    0

    from my observations it replaces the hyphens with spaces and then capitalises the first letter of each word and lowercases all other letters in the word.

    e.g.

    'SetValue-the-same.jpg' name is set to 'Setvalue The Same' I have not come across any where the word was not capitalised, do you have any examples?

  • Richard Thompson 13 posts 93 karma points
    Mar 10, 2023 @ 09:10
    Richard Thompson
    0

    examples below with original filename and then the filename it has in the media folder:

    KBBReview03 Kbbreview03

    kbb Kbb

    KBB202002 KBB202002

    IMG_0883 resized IMG 0883 Resized

    AZ5Y8477 AZ5Y8477

    I see you point with how it just capitalises the first letter, but then it seems to go a bit random on other files. I wondered if there was an Umbraco method that could be used to do the rename for us.

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Mar 10, 2023 @ 10:07
    Huw Reddick
    0

    As far as I can workout it is done here Umbraco.Core/Extensions/StringExtensions.cs there are several methods to do with prettifying the filename

  • Richard Thompson 13 posts 93 karma points
    Mar 10, 2023 @ 10:11
    Richard Thompson
    0

    Thank you for the help, I will take a look at that

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Mar 10, 2023 @ 10:18
    Huw Reddick
    100

    Hi Richard,

    after the - and _ are replaced with spaces, it does this

    CultureInfo.InvariantCulture.TextInfo.ToTitleCase(filename)
    

    Which gives the results you are seeing

  • Richard Thompson 13 posts 93 karma points
    Mar 10, 2023 @ 10:30
    Richard Thompson
    0

    That works fantastic, you're a legend. Thank you again

Please Sign in or register to post replies

Write your reply to:

Draft