What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

Including a URL in the alt text for an image breaks it, as long as the URL is preceded by a space:

Normal image

Alt text

Broken image

http://meta.stackoverflow.com">

share|improve this question
2  
More specifically, it happens in cases where the URL has a space before it. The auto-linker doesn't know better and tries to throw a <a> in there, which upsets the sanitizer...this is kind of in the same thread as a number of other escape-related issues, hrm. –  Tim Stone Jan 9 '12 at 18:59
    
@TimStone Ah, that makes more sense. I couldn't find a duplicate, but I didn't know exactly what the problem was; there might be one –  Michael Mrozek Jan 9 '12 at 19:13
    
I don't remember this specific issue coming up before, so I think you're good. Just trying to think of there's a good way to resolve all these issues at once, without (as balpha mentioned the other day) special-casing them all. –  Tim Stone Jan 9 '12 at 19:22
    
@tim if this issue hasn't come up before, I think the relevant question is do we care? I like to default to no. –  Jeff Atwood Jan 10 '12 at 1:21
5  
@JeffAtwood I'm inclined to care about cases like this because it's non-obvious what happens, so it's not immediately apparent to people that they just shouldn't do that. Admittedly the usecase here seems pretty limited (Michael, why were you trying to put a URL in the title attribute?), but if it's possible to address this along with the other auto-linker versus sanitzer issues then I figure "Why not?" –  Tim Stone Jan 10 '12 at 1:28
1  
Does this issue backtrack to markdown proper? –  jcolebrand Jan 10 '12 at 1:35
2  
@TimStone I was editing a post that left "enter description here", and the image was a screenshot of text that included a URL, so I tried to put the text in –  Michael Mrozek Jan 10 '12 at 3:06
    
Ah, makes sense. –  Tim Stone Jan 10 '12 at 14:00
2  
@JeffAtwood: By that logic, no bug would ever be fixed. Ever. –  Lightness Races in Orbit Jan 10 '12 at 19:08
    
@tom no, I'm saying if it has come up once in ~4 years it's not a very significant issue. And that's true. –  Jeff Atwood Jan 10 '12 at 19:27
1  
@Jeff: No, it's not significant, but defaulting to "we don't care" isn't a great way to push forward a programming project, IMO! –  Lightness Races in Orbit Jan 10 '12 at 19:33
    
@tom I unapologetically default to "we don't care" for issues that have come up once in four years. –  Jeff Atwood Jan 10 '12 at 19:36
    
@Jeff: Actually isn't it just a specific symptom of a more general bug, one that's come up a fair amount? (meta.stackexchange.com/questions/110470/…) –  Lightness Races in Orbit Jan 10 '12 at 19:51
    
@tom nope, it's the "why does the alt text for an image need to be a URL?" problem, which is unique as far as I know. Certainly in the four years I've worked on this project I've seen it come up hardly at all. Remember that alt text will NOT be clickable, it'll be plain text, so wanting a formal URL in there is.. bizarre at best. So I'll be reverting to my regularly scheduled "don't care" mode on this one. –  Jeff Atwood Jan 10 '12 at 19:58
    
@jcolebrand It doesn't track back to the original Markdown implementation because the auto-linker is a custom deviation. –  Tim Stone Jan 10 '12 at 20:04

1 Answer 1

up vote 6 down vote accepted

Since you indicated in comments you're trying to preserve the URL that's in the image, I suggest:

alt="www.foo.com"

Rather than

alt="http://www.foo.com"

Since the plain text alt for the image won't be clickable anyway, the http:// is irrelevant.

share|improve this answer
    
Indeed. And for users of screen readers I assume it is a bit nicer to have the URL read out aloud without the h-t-t-p-colon-slash-slash part. (If a URL is useful to start with then?) –  Arjan Jan 10 '12 at 20:09
1  
Also, if the URL is relevant enough to include in the alt text, it should probably be presented elsewhere in the post anyway. –  Tim Stone Jan 10 '12 at 20:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .