[a11y] Images with no text alternative should still have alt=""
📝 Provide a description of the improvement
How the feature works now and what you'd like to change?
Currently, if an image does not have a text alternative, the img element is generated in the data view with no alt attribute. According to the HTML spec for "purely decorative images", and accessibility standards, all img elements must have an alt attribute, but that attribute should be the empty string alt="" when the image does not add any information that would be described in the text alternative.
While the current code maintains an empty alt tag if it is added manually and loaded in through the data view, it does not add the empty alt tag by default to newly inserted images. I think this could be fixed by explicitly setting the alt attribute in insertImage if it's not passed in - but I'm not sure if that's the best place to do it. I can pass in an empty attribute when I call the insert command, and that will fix this in our editor, but it seems better if CKEditor were to generate accessible HTML by default, without me having to know this.
📃 Other details
-
ckeditor5-imageplugin - tested on v19.0.0
If you'd like to see this improvement implemented, add a 👍 reaction to this post.
Thanks for reporting this. We worked on it (#7405) but apparently, the patch was only partial.
To reproduce this:
editor.setData('<img src=x>');
editor.getData(); // -> "<figure class="image"><img src="x"></figure>"
The alt attribute should be present in the above scenario.
Having an explicit button to mark as decorative is a good practice. A11yfirst did this with CKEditor 4.
There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.