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.
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.
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?
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.
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
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
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?
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.
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
Thank you for the help, I will take a look at that
Hi Richard,
after the - and _ are replaced with spaces, it does this
Which gives the results you are seeing
That works fantastic, you're a legend. Thank you again
is working on a reply...