Decorative image feature doesn't add empty alt

Created on 14 February 2024, over 1 year ago

Problem/Motivation

According to https://www.w3.org/WAI/tutorials/images/decorative/ when using a decorative image an empty alt tag should be added but currently does not happen.

Steps to reproduce

Within a ckeditor that has the image upload button
Upload an image
Mark it decorative
Save page
Verify image does not have alt tag

Proposed resolution

Add an empty alt tag

Remaining tasks

Agree on solution
Add test coverage
Review

User interface changes

NA

API changes

NA

Data model changes

NA

Release notes snippet

NA

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
CKEditor 5 

Last updated 1 day ago

Created by

🇺🇸United States smustgrave

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

  • Issue created by @smustgrave
  • Status changed to Postponed: needs info over 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    There's explicit test coverage in HEAD to ensure this works correctly for decorative images

        // Ensure that the decorative image downcasts into empty alt attribute.
        $editor_dom = $this->getEditorDataAsDom();
        $decorative_img = $editor_dom->getElementsByTagName('img')->item(0);
        $this->assertTrue($decorative_img->hasAttribute('alt'));
        $this->assertEmpty($decorative_img->getAttribute('alt'));
    

    (Added in #3222756: Allow using images from external source .)

  • Status changed to Closed: cannot reproduce 5 days ago
  • 🇦🇺Australia acbramley

    Tested this using Standard profile and initially I was confused because it seemed as though I could reproduce it.

    However, my issue was that I simply didn't click the green tick after toggling on "Decorative image" to save the changes. After doing that the image correctly gets an empty alt attribute. There's even a warning over the image if you don't do this and leave the alt text field blank.

Production build 0.71.5 2024