Skip to content

v2.0.0 Automatically add aria-hidden to image tags with empty alt

Choose a tag to compare

@Silver0034 Silver0034 released this 13 Feb 15:42
· 7 commits to main since this release

New Feature: Render Filters Class

In this release, we've added a new class, Render_Filters, to enhance the accessibility of image blocks in your WordPress site.

The Render_Filters class automatically adds the aria-hidden attribute to the HTML of any image block that has an empty alt attribute. This helps screen readers ignore these images, improving the browsing experience for users with visual impairments.

Here's a brief overview of the methods in the Render_Filters class:

  • __construct(): This method adds the render_block filter, which is used to modify the block's HTML.
  • add_aria_label_to_empty_alt_tags(string $block_content, array $block): This method checks if the block is an image block and if the alt attribute is empty. If both conditions are met, it adds aria-hidden="true" to the <img> tag in the block's HTML.

This new feature is part of our ongoing commitment to making your WordPress site as accessible as possible. We hope it helps you serve your users better.