ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

[a11y] Images with no text alternative should still have alt=""

Open rshipp opened this issue 5 years ago • 4 comments

📝 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-image plugin
  • tested on v19.0.0

If you'd like to see this improvement implemented, add a 👍 reaction to this post.

rshipp avatar Sep 18 '20 21:09 rshipp

Thanks for reporting this. We worked on it (#7405) but apparently, the patch was only partial.

Reinmar avatar Sep 21 '20 08:09 Reinmar

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.

Reinmar avatar Sep 21 '20 08:09 Reinmar

Having an explicit button to mark as decorative is a good practice. A11yfirst did this with CKEditor 4.

mgifford avatar Oct 11 '23 15:10 mgifford

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.

CKEditorBot avatar Oct 10 '24 23:10 CKEditorBot