-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cover Block: Allow alt text for images #30505
Comments
I'm just finishing our new WordPress theme based on block patterns and I noticed the same problem today. I added alt text to the cover block to pass the theme check and it breaks the pattern, it throws an invalid content error. Theme check shows empty alt so it would be useful if you can find the solution. Thanks |
Same problem here: with the new embedded image in the cover block (which is generally a good move) the alt text is empty. In the JavaScript files packages/block-library/src/cover/edit.js on line 631 and in packages/block-library/src/cover/save.js on line 112 both it's set as empty string. Would be really great to have a field in block options to set or at least take over alt text if it is set in media library. I've never contributed to WordPress before and am not sure how to extend fields or where in the scope the alt text can be found. Maybe I'll have a look into contributor guides the next days. Hopefully someone else is faster. Thanks. |
It would be nice if the "alt" attribute could be added optionally to the cover block. |
To note, adding the attribute combination of Setting the |
Definitely seems like a missing piece. And I agree that having |
It seems like the best implementation for this would be to use the alt text set on the image in the media library, but allow the cover block image to be set as decorative to remove it. |
I have come across this issue today as well - If I manually add the alt text in the code editor and then save, the alt text is removed. I have alt text applied to the image in the media library, but it is not pulling this into the cover image. |
Same for me. Latest version. I tried all methods above and have the same results. |
I tested this too - it doesn't seem to pull the alt text from the media library at all. I actually hadn't noticed cover blocks now use It'd be fabulous if we could have alt text for covers blocks. |
Seems like this only solved 1 side of the coin, alt text for non-decorative images. With the alt left empty however, the block still fails a11y audits. I think that when the alt text field is left empty, the block should output Thoughts? |
I'm hesitant to suggest going straight to role="presentation" for an empty block. This doesn't solve accessibility but rather creates a blocker for automated accessibility testing. If users don't think it through, then it's failing to convey the text for a describable image, in which case you would want testing to catch it. I think the best solution would be to add a checkbox for Presentation Only to enable the |
Fair point about that, some users may not understand the impact of leaving the alt empty without context. I'd be fine with a toggle. |
Cover block markup includes an attribute for alt text, but there's no place to edit this in the block UI. If you attempt to edit this via the block markup, the editor throws an invalid content error.
Cover images are often decorative (and thus don't technically need alt text), but we can't assume that'll be the case all the time. Gutenberg should allow users to enter alt text here when it's needed.
Screenshots:
Example with default Markup:
Example markup with alt text:
The text was updated successfully, but these errors were encountered: