Problem/Motivation
The core UI has several form inputs for the configuration, and authoring, of the alt attribute on uploaded images.
The descriptions given about alt text:
- make bad use of the placeholder attribute (wysiwyg editor image dialog)
- contain misleading advice to suggest that text alternatives are intended for search engines (image field)
- are inconsistent
Proposed resolution
"Short description of the image used by screen readers and displayed when the image isn't loaded; important for accessibility."
- Put this advice in FAPI #descriptions, not #placeholder
- Remove mentions of SEO/search engines from the descriptions
- Make the advice for alt text consistent throughout core UI form descriptions.
Remaining tasks
Update the descriptions for alt text in these files:
core/modules/editor/src/Form/EditorImageDialog.php
(line 144)core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
Two places in this file: the "enable Alt field" checkbox (line 266), and the default image alt textfield(line 436)core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
(line 266)
User interface changes
Improve description text for alt attribute.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#45 | 2991149-45.patch | 3.4 KB | Angélique Valvandrin |
#39 | 2991149-39.patch | 3.39 KB | prashantgajare |
#36 | 2991149-36.patch | 3.38 KB | Angélique Valvandrin |
#26 | 2991149-26.patch | 3.38 KB | eli-on-drupal |
#29 | interdiff_26-29.txt | 928 bytes | eli-on-drupal |
Comments
Comment #2
Angélique Valvandrin CreditAttribution: Angélique Valvandrin at OVHcloud commentedHello all,
This is my 1st patch, thank you for your help!
Comment #3
nod_Comment #4
DuaelFrHi @Angélique Valvandrin
Thank you for your contribution and welcome to your first patch!
Two thoughts about it:
Comment #5
jds1I agree with both items mentioned by DuaelFr above. Maybe a description like "A short description of the image for screen reader users, often required for accessibility compliance."
Welcome to the wonderful world of patching! :)
Comment #6
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedAlways good to see a new patch contributor! Review of patch #2:
Text alternatives aren't for SEO - they're for people. It's true that search engines use the content, but they aren't the intended audience of the alt attribute. I'd prefer we don't mention SEO here, because I think it's a bit misleading. I've seen some truly terrible examples. keyword-stuffing in alt attributes, written by people whose sole concern was SEO.
Hmm, screen readers announce the alt attribute regardless of whether the image has loaded.
Re: #4.2
I agree, this isn't a good use of the placeholder attribute. Let's use the #description only.
Re: #5
That's a start, but it only covers some situations. I like the phrase used in WCAG 1.1.1 Non-text content - a text alternative "serves the equivalent purpose".
I don't like this, it reinforces the policy-checkbox mentality, and completely misses the point of what text alternatives are actually for: understanding. How about "important for accessibility".
Fun fact: the word "compliance" doesn't appear anywhere in the WCAG 2.0 rec.
Somewhere there's an issue about improving the help text for imagefield configuration too, but I can't find it. I'll link it here when I do, it would be good to get them consistent.
There's lots of potential to bikeshed on this phrasing, and I'm guilty as anyone ;-)
Comment #7
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedSomething we can definitely go ahead with: remove the #placeholder attribute, just use #description.
Comment #8
dat deaf drupaler CreditAttribution: dat deaf drupaler as a volunteer commentedDropping by to leave a comment.. deaf people *do not* use screen reader.. it is mostly for blind and visually impaired users.
However I am cool with using "for people with disabilities" regardless. But still, I agree with comments #4, #5, and #6 above as it sounds more appropriate without discriminating anyone with disabilities.
Thanks for the patch!
Comment #9
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commentedHere's a patch combining the changes requested above.
Comment #10
DuaelFrThe last patch looks good to me.
I am a bit surprised it doesn't break any test, though.
Comment #11
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commented+ '#description' => $this->t('Short description of the image used by screen readers; important for accessibility.')
The alt attribute isn't just used by screen readers. It is displayed visually if the image isn't loaded.
Comment #12
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commentedI think this wording covers all the bases.
Comment #13
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedReview of patch #12:
The coding standards prefer to avoid escaping single quotes in translated strings. Let's convert this to the double-quoted form.
Comment #14
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commentedHere's a final version using double-quotes.
Comment #15
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commentedComment #18
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commentedComment #19
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedComment #20
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commentedComment #21
alexpottWe already have text for this in the ImageWidget see
If we used the exact same text then existing translations would work and they wouldn't have something new to translate. I think the fact it is required shows that it is important (for accessibility and other reasons) so we don't really need that bit.
+1 to making it a description so this help text remains even when editing an image via ckeditor.
Comment #22
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commentedHere's a patch with the requested wording.
Comment #23
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedSorry, but #21-22 are going in the wrong direction. I agree it would be good to get these descriptions the same, but let's not use the existing ImageWidget description. Search engines aren't the intended audience for text alternatives. The ImageWidget description is misleading because it suggests you should write alternative text with search engines in mind.
Somewhere there is an issue to update the ImageWidget text too, I just can't find it. We could change both of them here, and close the other one later (when I find it....).
Only if you already happen to know what the alt attribute means. In my experience content authors are often confused or misinformed about it's purpose.
Accessibility is the only reason for text alternatives - all of the benefits of text alternatives given in the HTML5 recommendation amount to accessibility. Search engines aren't mentioned at all in relation to text alternatives in either the HTML5 or WCAG recs.
Comment #24
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedWow, the current ImageWidget description has been with us since the 5.x-2.5 release of imagefield module in contrib! I went looking for it, found the origin in #366078-1: improve ALT text field description...
So it really was a sly plan to encourage accessibility dangling an SEO carrot. To be fair, I've done this myself in the past, but these days I don't think it's responsible advice.
Comment #25
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedUpdating issue summary.
I found another place which needs fixing, in the image field settings form (ImageType)
Comment #26
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commented+1 for @andrewmacpherson's opinions on the matter. Here's a patch with all of the changes.
Comment #27
Angélique Valvandrin CreditAttribution: Angélique Valvandrin at OVHcloud commentedHi,
I have tested and I agree with eliclaggett's patch.
Comment #28
alexpottI'm not sure this checkbox description should be changed. This is about enabling the field so the text "Enabling this field is recommended." is important and directly ties to the description for the title_field checkbox.
Comment #29
eli-on-drupal CreditAttribution: eli-on-drupal at Mindgrub Technologies commentedI see what you mean alexpott. Here's a patch that should convey how enabling alt text is important.
Comment #30
nod_Looks good to me :)
Comment #31
TwoDSmall nitpick: "isn't" should be "is not" in all occurances.
See the interface text guidelines
on https://www.drupal.org/node/604342
Comment #32
TwoDComment #33
Angélique Valvandrin CreditAttribution: Angélique Valvandrin at OVHcloud commentedComment #34
Angélique Valvandrin CreditAttribution: Angélique Valvandrin at OVHcloud commentedHi, please find "isn't " to "is not" fix.
Comment #35
Angélique Valvandrin CreditAttribution: Angélique Valvandrin at OVHcloud commentedThx :-)
Comment #36
Angélique Valvandrin CreditAttribution: Angélique Valvandrin at OVHcloud commentedComment #37
nod_yay for guidelines :)
Comment #38
DuaelFrGood job here! I think we are really close to a commit! :)
As a translator, I think these strings should be split so we could prevent translations duplication.
I suggest the three following strings:
As an example:
Another nitpick: according to best practices, the strings which do not contain any single quote should not be encapsulated in double quotes.
Comment #39
prashantgajare CreditAttribution: prashantgajare as a volunteer and commented@DuaelFr I think we can add translation for the whole paragraph of the description. Added the updated patch regarding quotes to keep the consistency.
Thanks!
Comment #40
prashantgajare CreditAttribution: prashantgajare as a volunteer and commentedComment #41
nod_Can we get an advice whether #38 is the way to go? I've always been told to keep sentences whole because of context. I do understand the benefit of splitting but couldn't find documentation on whether we should do that or not. Also haven't examples in core where we do that.
Comment #42
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedAlso re: #38, concatenating two t() strings means we are dictating to translators about which order the sentences must presented. That sounds like an unnecessary constraint to me. I'm not a translator, but someone who is explained that flexibility here can be useful. I understand that's why we include links as placeholders inside the whole string instead of concatenating them. Core already has plenty of short descriptions with two sentences in one string.
If we stick with the single string approach in #36, it would be worth replacing the semicolon with a full-stop here:
The semicolon is being used correctly here, but a lot of native English speakers aren't confident about them, and it feels a bit technical. A full stop could make it more readable English.
Comment #43
vijaycs85+1 to #42. Surely this is new. Core has plenty of examples where all string in one t()
Comment #44
jhodgdonRE #38, you're actually making 2 different translatable strings into 3 somewhat shorter ones. None of the strings is very long anyway. I think keeping them whole as 2 strings is probably better?
In any case, I would actually say to change this string:
Short description of the image used by screen readers and displayed when the image is not loaded; important for accessibility.
to either:
Short description of the image used by screen readers and displayed when the image is not loaded (important for accessibility).
or as kind of suggested in #42
Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.
Comment #45
Angélique Valvandrin CreditAttribution: Angélique Valvandrin at OVHcloud commentedTaking #44 comments into consideration.
Thx
Comment #46
nod_Looks good to me: Single strings, single quotes, no contractions, no semi colons.
Comment #48
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedComment #50
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedComment #52
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedComment #54
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedI found the duplicate issue I mentioned in #6 & #23. I've closed that one and brought credits across.
Comment #55
alexpottCommitted 36ff61a and pushed to 8.7.x. Thanks!