Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Assuming that a file is uploaded with a space in the filename like "myimage home.jpg".
background:url(umbraco.library:GetMedia(data [@alias='afbeelding'], 0)/data [@alias='umbracoFile']) no-repeat
background:url(/media/23609/myimage home.jpg) no-repeat
Using the above method won't work.
How can I get around this problem withoud having to split the "umbracofile" string and use urlencoding on the filename alone?
You really ought to include quotes with the url tag, which would resolve the problem I think.
The output you're looking to generate would be
background:url("/media/23609/myimage home.jpg") no-repeat
Wich browser do you use Ron?
Sometimes Internet Explorer can have different issues with filenames. One of them is when a "space" is a part of the filename just like in your example. Other things such as uppercase letters or special characters(æ, ø, å, ö, ó etc.) can mess things up.
It's a good idea to only include lowercase characters, underscore(_) and hyphens(-) in your filenames.
But Doug also have a point. Sometimes quotes can make a difference as well.
And by the way. Remember the semicolon (;) at the end after the no-repeat.
Thats right Douglas, I already figured that out..
However it would be nice if it could be encoded.But my problem is solved for now.
@kim "It's a good idea to only include lowercase characters, underscore(_) and hyphens(-) in your filenames. "
thats what I tel my clients but they won't listen :p
Bumping into this post. Filenames with spaces and non-english characters also causes validation errors. I agree that it would be nice if it could be encoded as Ron said. Files can be saved that way in all kinds of os'es but the web does not like it so encoding should be the way to do it.
umbraco.library:UrlEncode might help here, but there does come a point where the client needs to continue any validation efforts!
We used Media.SaveEventHandler() to handle this. Few lines of code. It resaves with nice name + changes the filename property. Works fine as far as I've tested yet, need some more testing + add the thumbnail, if there's interest we'll upload it as a small package (only include the dll and voila).
That sounds like a good package - Please consider adding it to our :-)
I would like that package too. :)
Have you considered uploading it to Our?
Hi, yes, we made such a function, but it breaks Multiple File Upload at the moment, thats why it's still not published anywhere. My approach for it to run at the moment is to run once on a nightly schedule.
Ok - thanks for your answer. :)
Is it possible for you to share the lines of code, not necessarily the whole package? Then we can implement and use it on our own risk.
Hi, just one year late ... I stumbled on this thread and noticed I forgot to respond with the link to the wiki where the snippet is : http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/event-examples/adjust-media-file-so-it's-url-friendly
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted