Skip to content
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

Add featured image alt text #66189

Merged
merged 4 commits into from
Oct 18, 2024

Conversation

prajapatisagar
Copy link
Contributor

Addresses part of #66005

What?

This PR ensures that when an image fails to load (i.e., is broken), the alt text is displayed in its place. If alt text is not provided, the image name will be displayed instead.

Why?

This update improves accessibility and enhances user experience by providing context when an image fails to load. Instead of leaving a blank space or displaying a broken image icon, the alt text or image name will be shown, offering users helpful information.

How?

The implementation involves updating the image rendering logic to check if the image fails to load. If it does, the alt text (if available) will be displayed. If the alt text is not provided, the image name will be used as a fallback display.

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

Alt Text 1
Alt Text 2

Copy link

github-actions bot commented Oct 17, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: prajapatisagar <sagarprajapati@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@akasunil akasunil added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Editor /packages/editor labels Oct 17, 2024
@afercia
Copy link
Contributor

afercia commented Oct 17, 2024

Thanks @prajapatisagar !
The same code is in use for the text used for the aria-describedby. To avoid code duplication, I'd suggest to abstrat it if possible to a small helper function and use that function for both the aria-describedby and the alt attribute.

Copy link
Contributor

@afercia afercia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @prajapatisagar LGTM.

@afercia afercia merged commit 9d2b320 into WordPress:trunk Oct 18, 2024
62 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.6 milestone Oct 18, 2024
karthick-murugan pushed a commit to karthick-murugan/gutenberg that referenced this pull request Nov 13, 2024
* Add featured image alt text

* Updated duplicate code to function.

* Modify doc

* Minor adjustments for the docblock.

---------

Co-authored-by: prajapatisagar <sagarprajapati@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants