Making accessibility usable for content editors adding image alt text

Searched words: drupal 8 mark required alt text as not informative

Alternate text for uploaded images became required by default in Drupal when “Make the default ‘alt’ attribute for Image fields required” was fixed in 2015, and that’s great.

Make it Easier for Views with Images & Links to be Accessible”, which is still open, raises the point that in different contexts alt text might not be desired or should be different. (In my opinion, the solution to those examples, like when an image is part of a teaser that links to the full content, is to blank out the alt text (alt="") and allow other text to do the work.)

I agree with kattekrab in the default ‘alt’ attribute to required issue’s comment #83:

I have been wondering if the core image field should mimic the behaviour you see when adding an image via ckeditor.

In that the user is prompted to add "" to explicitly make an alt field empty.

Even better, it should be a checkbox: “This image is decorative and provides no information not already present in text.”

Pretty easy to fake that checkbox with JavaScript rather than figure out how to make two form elements in Drupal, one which becomes not required when the other is submitted, and to make certain that the empty alt is printed so screen readers don’t read the image filename, etc. Since no one else has created that functionality, i guess i will.

Allegedly this has been done in core for WYSIWYG fields that allow inline image insertion: #2307647: [Follow-up] Allow manual override of required image alt text in the Text Editor image dialog when appropriate. However, i have never seen that option.

Ohhh, that proposal got dropped in the 50-odd comments that this simple proposal went through, and the message is only given when you try to submit the form, as a helper in the error message, ugh. For the record, here’s that message:

Alternative text is required.
(Only in rare cases should this be left empty. To create empty alternative text, enter "" — two double quotes without any content).’)

So, we’re back to where i started: making accessibility usable. Information that’s only shown to you when you ignore the red asterisk of requirement and try to submit anyway is not friendly.

(To be clear, i disagree with Wim Leers’ vigorously maintained claims throughout that thread that empty alt text is “extremely rare” and that functionality that helps people understand how to use alt text properly is clutter in the user interface.)

But like many, i don’t have the energy to do battle in core, so taking this to contrib.