Image: Remove redundant role attribute from frontend markup - #79617
Image: Remove redundant role attribute from frontend markup#79617yashjawale wants to merge 5 commits into
role attribute from frontend markup#79617Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
If we want to move forward with this PR, please be aware of #79572 (comment). |
|
Ah right! If I remove the But it looks like if we add From what I checked, this was tried in #75027 (comment) but at that time it didn't prevent Safari from reading the image itself. But looks like now it does. Perhaps this is the way to go now? My test environment: Screen.Recording.2026-07-21.at.2.00.27.PM.movAlso updated the PR description |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |

What?
Closes #79572
Why?
When "Mark as decorative" option is enabled it adds
role="none"attribute which is not needed & causes HTML validation warnings.Also applies to gallery block.
How?
The attibute was added to fix an issue in Safari Voiceover where it used to read out file names even if alt text was empty for decorative images.
While adding
roleattribute fixed the Safari issue it introduced HTML validation warnings as in presence ofrole,altattribute should be present & be non-empty. Which can't be the case for decorative images.This PR shifts to use
aria-hiddenattribute instead ofroleto prevent Safari Voiceover issue while still generating valid HTML code.(This was previously tried in #75027 (comment) but looks like it didn't prevent Safari from reading out images, which now it does)
Testing Instructions
roleattribute is no longer presentaria-hiddenattribute being addedScreenshots or screencast
Screen.Recording.2026-07-21.at.2.00.27.PM.mov
Use of AI Tools
None