There is always an "alt" attribute for all the links generated by "Views" and this is not compliant with the W3C recommendations, the "a" tag does not have an "alt" attribute. The "title" attribute, that is set at the same time, is the right way to provide a more complete and more accessible description of the link... so I guess we should remove this "alt", but since I am not experienced with Views and all its functionality I think it is better just to report this and let a qualified "Views" developer handle this ;)
I located two place where Views could be modified to remove "alt", but I don't want to create the patch for this, because I am pretty sure that this code has a reason to exist (for images maybe ?), so maybe this helps to nail down the problem.
Near line 517, modules/views/handlers/views_handler_field.inc :
$alt = $this->options['alter']['alt'];
$alt = strtr($alt, $tokens);
Near line 517, modules/views/modules/node/views_handler_field_node.inc :
$this->options['alter']['alt'] = check_plain($data);
Hopefully this will help... oh and this might very well have been introduced with the patch committed in #399534: Add fragment and query to render_as_link, because before Views wasn't adding this "alt" attribute.
Comment | File | Size | Author |
---|---|---|---|
#27 | views-489888-1.patch | 540 bytes | gargoyle |
#2 | views-489888.patch | 612 bytes | TheRec |
Comments
Comment #1
TheRec CreditAttribution: TheRec commentedHmm my bad... that other issue has surely not introduced this bug, it seems that this code was there already before that patch.
But this one did I think : #377896: When ticked "link to node" show node title as a href title attribute
Comment #2
TheRec CreditAttribution: TheRec commentedWell, I'll give it a try... after few tests and since this function is called "render_as_link" (so it shouldn't render anything else), I think it is safe to just remove the "alt" attribute of links.
Comment #3
TheRec CreditAttribution: TheRec commentedComment #4
Dret CreditAttribution: Dret commentedHi to all and Thanks for the patch!
A request more... if possible:
For Web Accessibility standard all link must have the "title" attributes (and all the images the "alt" one).
It's possible in the next releases to work for this target?
The last patch correct the problem above but actualy not all link field have the "title" avaiable.
Thanks!
Bye!
Comment #5
TheRec CreditAttribution: TheRec commentedSure this should be worked, at least the possibility set the "title" attribute of anchors, if wanted/needed (it should not be an obligation) and "alt" attribute should be mandatory for images (even if it is empty..). Anyways you should create an issue for this in my opinion, that patch (for a bug!) still needs to be reviewed before maybe being committed. Making this issue a feature request won't help to correct that bug.
Comment #6
TheRec CreditAttribution: TheRec commentedComment #7
balabushka CreditAttribution: balabushka commentedSubscribing... also suffering from that bug :-)
Comment #8
antiorario CreditAttribution: antiorario commentedSubscribing.
Comment #9
B00N CreditAttribution: B00N commentedSubscribing.
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedIf you subscribed and did not test and report on the patch, SHAME ON YOU.
Comment #11
gbrussel CreditAttribution: gbrussel commentedConfirmed. Applied the patch, links no longer spits out the
alt=""
attribute anymore. If you could do the same for removing imagetitle=""
in this patch (unless that would kill kittens), it'd be nice.Comment #12
TheRec CreditAttribution: TheRec commentedI would really like to find where the "title" might be set for img, but I cannot find any place in Views where it renders images with such attribute (in fact I couldn't find a place where image are rendered with views handler or other parts of the module :) ... it is not my module, but I searched the code with 'img', 'image' 'title', and 'alt' and nothing relevant showed up)... wouldn't it rather be an issue in CCK or ImageField or Image ? If so, then you should create an issue in their queue.
Comment #13
fenstratConfirmed, works as stated - the invalid
alt
attributes on<a>
elements are gone.The
title
tag should not be removed as it is valid html.Comment #14
TheRec CreditAttribution: TheRec commentedThanks for the feedback.
Sure it won't (at least in my opinion)... but it should be optional for anchors (
<a>
), because it is optional in some cases (for example when the anchor text is describing the content of the link with enough details). So maybe, if anyone needs it, he/she could make a feature request to make this "title" attribut optional ;)Comment #15
shelleyp CreditAttribution: shelleyp commentedJust wanted to confirm that the patch worked on my seven Drupal sites. Thanks!
Comment #16
VM CreditAttribution: VM commentedThis would need to be added to 3.x-dev as well, patch does indeed apply to 3.x and does indeed remove the alt tag from
<a>
Comment #17
andyceo CreditAttribution: andyceo commentedSorry, may be this is offtopic, but something like that problem we discover here: A wrong "alt" and "title" attributes in "a" tag for imagecache images.
Comment #18
auberdjinn CreditAttribution: auberdjinn commentedThanks, this patch worked for me.
Comment #19
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted to 2.x and 3.x branches.
Comment #20
DamienMcKennaAs someone who just ran into this little bug, thanks to all who contributed to getting it resolved!
Comment #21
GuillaumeDuveauSame as Damien, thanks everybody !
Comment #22
noahterp CreditAttribution: noahterp commentedI wanted to point out that the
title
attribute is not required on links. It is actually bad for accessibility and usability if the title is simply duplicating the actual link text.Think about these situations:
1. A screen reader is speaking a page, and upon reaching one of these links, will read out both the link text, and the
title
attribute. So the visitor is now subjected to the same text twice for no apparent reason.2. I'm just browsing the site and move my cursor over a link. A tooltip pops up showing me text, which I am conditioned to skim and expect to provide me additional information about the link. But instead, it's the same as the link text and ends up eating a second of my time as I have to process that basically useless info.
"Web accessibility" standards only say to use the
title
when it has additional, non-critical information about the link. So I recommend adding a quick comparison and not showing thetitle
attribute if it's identical to the link text.That quick fix should just mean changing line 519 of views_handler_field.inc from:
if ($alt) {
to
if ($alt && $alt != $text) {
Comment #23
GuillaumeDuveauGood point, but could you post this as a new issue please ?
Comment #24
TheRec CreditAttribution: TheRec commentedThanks for the precision noahterp, that was exactly my point in #14 ;)
Comment #25
noahterp CreditAttribution: noahterp commentedSorry, I thought I would continue this discussion (since the title attribute was mentioned a few times) instead of making a new issue. It's now listed at #507884: Remove matching title attribute on node links.
Comment #27
gargoyle CreditAttribution: gargoyle commentedSorry for re-opening this, but I was following through this thread after discovering the same issue with one of my sites. However, I patched .../views/modules/node/views_handler_field_node.inc which includes a very similar line to the one from the previous patch...
Line 48 should be removed I think.
I have attached a patch, but it is my first one - ever. So someone else should check I have done everything correctly...
Comment #28
TheRec CreditAttribution: TheRec commentedThis is not related to the original issue. And what you are doing in your patch is already waiting to be reviewed here (for a moment) : #507884: Remove matching title attribute on node links
Comment #29
Mac Clemmens CreditAttribution: Mac Clemmens commentedTested and works great!
Comment #30
ridolfidesigns CreditAttribution: ridolfidesigns commentedI am running ver 2.6 for Drupal 6 and I am still receiving this problem.
Comment #31
TheRec CreditAttribution: TheRec commentedMost likely because the version you run was out on "2009-Jun-10" and this issue started on "June 12, 2009" and the fix got commited on "June 26, 2009 - 00:04". In short words, you'll see this in the next stable, right now it is only in the -dev snapshot and on CVS.
Comment #32
ridolfidesigns CreditAttribution: ridolfidesigns commentedAh yes, thank you for that little detail. I will run the patch.
Comment #33
lennartalserda CreditAttribution: lennartalserda commentedThanks for this patch.
I seems t work fine :)
Comment #34
mgiffordYup. We ran into this issue too. alt tags should never be used with an anchor. Please bring views-489888-1.patch into core!
Comment #35
gmh04 CreditAttribution: gmh04 commentedThis patch works for me
Comment #36
Narno CreditAttribution: Narno commentedviews-489888-1.patch works for me too! thx
Comment #37
Summit CreditAttribution: Summit commentedHi, Is this patch also in latest 2.8 views?
Greetings, Martijn
Comment #38
archimedes CreditAttribution: archimedes commentedThis patch was committed and put into the Views 6.x-2.7 (http://drupal.org/node/621428) release. It should thus carry over to 6.x-2.8.
Comment #39
nocean CreditAttribution: nocean commentedI'm using Views 6.x-2.11 and am seeing "Alt text:" in the "Output this field as a link" section, with no ability to add a "title" attribute. Did this fall off somewhere between 2.7 and 2.11?