Stemming from #2303765-83: Make the default 'alt' attribute for Image fields required, if you have a thumbnail View of an image in a link, "that alt text should provide direction on what the link is, not necessarily describe the image."
How do we make this easier to build in Drupal 8? Certainly, it might be possible to find an easier way to pull in a title into the View.
Is there a way to make this more user friendly? How do we make this the default behaviour?
Original issue:
Many images in image fields, as opposed to those uploaded via wysiwyg - are used in multiple locations. Commonly this becomes a thumbnail, which is then linked through to the node it originated from.
When that image becomes a link - it MUST have alt text, and that alt text should provide direction on what the link is, not necessarily describe the image.
This was "solved", by instructing users to make the alt text the same as the title of the node, but that's not a great solution. We're also using a default image for some nodes. We considered adding a snippet of code to automatically copy the node title into the alt text field for the thumbnail in a view list. But that is also clunky.
The end result for users with screen readers is a stutter. The image link is right next to a title link, both of which repeat the title of the node. Which gets flagged as non-compliant by accessibility checkers :/
Comments
Comment #1
kattekrab commentedComment #2
kattekrab commentedCopied in the text from the comment so I can follow up and track this.
I feel there has to be a better way, but I don't know what that way might be!
Comment #3
kattekrab commentedBumping this to 8.1 though.
Comment #4
dawehnerWhat about also somehow include the field label, would that improve the situation?
Comment #5
mgifford@dawehner where would you put the field label? Ultimately we need to be able to add alt text with a view and provide flexibility such that it isn't necessarily the alt text associated with the uploaded image.
Comment #6
dawehnerWhat we could do:
{{ desciption }}Comment #7
mgiffordOk, that sounds like a plan. I'm hopeful in that we can nudge this back to the 8.0 release rather than the 8.1, but if we don't get a patch for this soon, obviously it wasn't meant to be.
Comment #19
tgoeg commentedWhat is the current best practice/workaround to get this fixed in the meantime? Not being able to use images as links altogether just because of a11y incompatibility is pretty cumbersome.
After searching high and low and fiddling with it, I use a link override like this now
i.e. in lack of a regex search/replace I use the tag as an anchor, assign the old value of
altto some unused attribute likeimage-descriptionand setalt={{ title }}(of the content I want to link to) instead.Just using
replacemakes the view put out escaped ankle brackets. I am a twig-noob, so maybe there is some drawback to doing it like this or there is some other magic incantation to stop that from happening?field_image|raw|replacedoes not seem to work, either.One really easy solution (I think, and the place I would have expected it most) would be to offer a field for
altalongside the other (Link class, Title text, Rel Text ..) below "Output this field as a custom link". Everyone could override it with whatever they see fit. If it supports twig and variable replacement, that is.Considering that this ticket is 7 years old, some kind of official intermediate solution/how to/documentation should be provided. Maybe with the method I outline above.
Fixing it would also be a solution (but as I am not a dev I don't want to sound pushy but try to provide a workaround at least) :-)