Re: Are spaces allowed in image names?

Katie_DenHollan
Level 3

Are spaces allowed in image names?

I just noticed that all the images for our email template headers were uploaded with spaces in the file name. I thought I had learned that you could not have spaces in the file names in Marketo because it would break the link for the image.

However, I can't find any information on that now. Also, when I send a sample email, the header shows up just fine.

Any help is appreciated!

Thanks!

8 REPLIES 8
Scott_McKeighe2
Level 5

Re: Are spaces allowed in image names?

While I don't think it's explicitly forbidden, spaces in naming conventions are notoriously unreliable. If I were in your shoes, I would add simple hyphens in place of those spaces ("my-file-name.xxx") so as not to accidentally discover a problem later with a URL being mutated or broken.

All that said, it's also reasonable to stick with, "if it ain't broke, don't fix it."

Josh_Hill13
Level 10 - Champion Alumni

Re: Are spaces allowed in image names?

Totally agree. Never, ever upload a file to marketo (or web) with spaces. Marketo is not reliably putting %20 in the space. Your URL will break and the lead will think you are a bad company.

Always use dashes in filename before you even upload it.

Bonnie_Jeffers2
Level 4

Re: Are spaces allowed in image names?

Hi Josh, I totally agree with you and (wrongly) assumed our practitioners would know this about urls in general, but they don't. Do you have a not-so-technical way to explain why it's important to only upload files with hypens/underscores rather than spaces?

Here is what I tell my users when they can't understand why something is broken and due to spaces in their file names, but I'm wondering if there's a clearer way to say it.

"The space character is not allowed in URLs. Marketo will create one for you, but HTML cannot parse the space character.  So when someone clicks a link that contains a space, HTML replaces every space with %20.

So if you are trying to triggering an action based on:

Clicks Link http://go.epicor.com/rs/ABC-123/images/My File Has Spaces.pdf

what you really would want to track is:

Clicks Link http://go.epicor.com/rs/ABC-123/images/My%20File%20Has%20Spaces.pdf

but don't do that either. Best practice is to upload your files with hypens or underscores such as:

http://go.epicor.com/rs/ABC-123/images/My-File-Has-Spaces.pdf or http://go.epicor.com/rs/ABC-123/images/My_File_Has_Spaces.pdf

Thanks for any thoughts on this.

SanfordWhiteman
Level 10 - Community Moderator

Re: Are spaces allowed in image names?

How about something like this:

"Files stored on hard drives (on OS X, Windows, Android, or any other OS) are allowed to have spaces. But URLs may or may not be allowed to have spaces, depending on where they're used and on which browsers and apps access them.  Where spaces are disallowed in URLs, they must be encoded (transformed) into either the string '%20' or the plus sign '+'.

Adding to the confusion, sometimes encoding happens automatically when a link is clicked, but other times the same URL will cause an error because it does not have spaces already encoded.

This set of possibilities creates too much ambiguity in web analytics. As a result, it is not recommended that spaces be used at all, whether or not they are pre-encoded. Instead, use hyphens or underscores.  Either one is okay, but underscores are safer for use in all contexts because they do not conflict with a common special character (the minus sign)."

Bonnie_Jeffers2
Level 4

Re: Are spaces allowed in image names?

I think your answer is more thorough than mine and makes sense. Thanks for your input!

SanfordWhiteman
Level 10 - Community Moderator

Re: Are spaces allowed in image names?

I know this is a zombie thread, but Scott​ you might be interested to know that unencoded spaces are indeed explicitly forbidden by the current URI standard (RFC 3986).  The standard makes no judgments about encoded spaces, however, which is why they're free to be used, despite the confusion they may cause.

And guaranteed to add to the confusion is that in HTML5 (i.e. where you add hyperlinks) spaces surrounding URIs are totally fine, as are Unicode non-breaking spaces within the URI. That is:

     <a href="  http://example.com/this path   blatantly has   spaces/in it.html  ">Click me</a>

is valid HTML5!*

But that href with spaces is not a valid on-the-wire URI.  So when you click it, the browser must strip off the leading and trailing spaces and URL-encode the spaces in the middle.  You can see why it gets confusing when you can put this link in HTML and think it "works" when in the wider sense it can't be used in an HTTP request (and some browsers may not correctly encode it).

* Some parsers will erroneously choke on it, but it should left alone.because an HTML5 document doesn't get validated based on what might happen if someone clicked a link.

Scott_McKeighe2
Level 5

Re: Are spaces allowed in image names?

Wow... That's definitely interesting, and seems like a good case for a self-imposed naming convention.

Srujan_Vishwana
Level 4

Re: Are spaces allowed in image names?

The best practice which has worked for me is following this naming convention: My_image_name_abc_xyz

This will not only avoid the spaces but will also hide the underscore giving it a look of not having space and still there is no link breakage. Hope this helps.

Cheers,

Sru