Skip to content

A11y: Decorative images in a figure element cause VoiceOver screen reader reading the file name. #75027

@juliemoynatPro

Description

@juliemoynatPro

Description

When you add an image in a post, it is put inside a figure HTML element, which is a semantic HTML element.

So, when the image is decorative, it should not be inside a figure but it is.

So, VoiceOver, the screen reader for MacOS and iOS, does not ignore these images because the figure tells that they're not decorative images. And VoiceOver reads the filename for the images because the alt attribute is empty (alt="").

In order to fix it:

  • Recommended: Only images with a caption (figcaption element) should be inside a figure element;
  • Or, you can eventually add an aria-hidden="true" attribute on figure only when the image has no alternative text.

Step-by-step reproduction instructions

  1. Add an image block in a post with an image without alternative text;
  2. See the code (an img element with empty alt attribute (alt="") inside a figure element);
  3. Make VoiceOver (on MacOS or iOS) read the image: it will read the filename;
  4. Move the image outside of the figure (with the browser inspector) and VoiceOver will ignore the image as it should do.

Screenshots, screen recording, code snippet

Example of generated code to understand:

<figure class="wp-block-image size-large">
  <img loading="lazy" decoding="async" width="1024" height="573" data-id="136327" src="https://example.com/wp-content/uploads/2025/01/image-1024x573.jpg.webp" alt="" class="wp-image-136327" srcset="https://example.com/wp-content/uploads/2025/01/image-1024x573.jpg.webp 1024w, https://example.com/wp-content/uploads/2025/01/image-300x168.jpg.webp 300w, https://example.com/wp-content/uploads/2025/01/image-150x84.jpg.webp 150w, https://example.com/wp-content/uploads/2025/01/image-768x430.jpg.webp 768w, https://example.com/wp-content/uploads/2025/01/image.jpg.webp 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px">
</figure>

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TestingNeeds further testing to be confirmed.[Block] ImageAffects the Image Block[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.[Type] BugAn existing feature does not function as intended

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions