When an image is part of a View (in my case, a table) and made to link to a node, the alt and title text of the link are corrupted. For example, here is the output from one field:
<a href="/node/8" title="&lt;img src=&quot;/sites/default/files/image.jpg&quot; alt=&quot;&quot; width=&quot;90&quot; height=&quot;90&quot; id=&quot;imceimage-field_picture-0&quot; /&gt;" alt="&lt;img src=&quot;/sites/default/files/small_image.jpg&quot; alt=&quot;&quot; width=&quot;90&quot; height=&quot;90&quot; id=&quot;imceimage-field_picture-0&quot; /&gt;"><img src="/sites/default/files/small_image.jpg" alt="" width="90" height="90" id="imceimage-field_picture-0" /></a>
This might be a bug with Views, but I think it's more likely that IMCEImage is feeding it bad information or no information.
Comments
Comment #1
shashi_lo commentedThis is what I did. Replace this line
$alt = strtr($alt, $tokens);With this
$alt = ""Comment #2
danepowell commentedI can't find the code that you're referring to - can you provide a patch? Are you sure that applies to 6.x-1.0-beta2?
Comment #3
danepowell commentedAh, you failed to mention that you were talking about Views :) I suppose that would solve it. But I guess this is really a Views issue then. I'm not sure if it's exactly a duplicate or not. Here are the related issues that I found:
#496010: A wrong "alt" and "title" attributes in "a" tag for imagecache images: Pretty much a duplicate. Unfortunately merlinofchaos has already closed it as a duplicate of...
#489888: alt attribute set for node fields rendered as link produces not compliant HTML which has a patch that only half solves the problem (gets rid of alt attribute but leaves ugly title attribute). So I'm not sure if it's actually a duplicate or not.
You know, it looks like Views is blindly pulling the title attribute for links from whatever is contained in the links. Obviously a behavior that is intended to work with plain text links, but produces garbage for image links.
Comment #4
danepowell commented(updating the title to reflect what I think is the real problem, after dealing with the corrupt alt text)
Comment #5
dwwThis is probably now resolved thanks to #507884: Remove matching title attribute on node links. Please reopen if you try with the latest views code from HEAD and you're still seeing a problem.