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

Accessibility tweaks for blog posts' featured image component #3953

Open
5 tasks
beepdotgov opened this issue Jun 26, 2024 · 0 comments
Open
5 tasks

Accessibility tweaks for blog posts' featured image component #3953

beepdotgov opened this issue Jun 26, 2024 · 0 comments

Comments

@beepdotgov
Copy link
Member

Expected Behavior

While pairing on #3862, I noticed that the "featured image" component on blog posts (example 1, example 2, example 3) uses some potentially inaccessible markup.

From the visuals, I expected the image would have been marked up as an img element, with an alt text containing its text equivalent, and some CSS (e.g., cover) to control its layout.

Actual Behavior

Here's the relevant bit of _includes/feature-image.html:

<figure class="post-feature_image" role="img" title="{{ include_image_alt }}" style="background-image: url('{{ site.baseurl }}{{ include_image }}')">
   [ … ]
</figure>

The featured image is currently rendered as a background-image on a figure element, with a title attribute used for the image's text equivalent. And visually, this looks beautiful! With that, it's worth noting that the title attribute isn't especially accessible (reference 1, reference 2), which means many users may not be able to access the image's description.

Also, the presence of role="img" could mean that the contents of the image (like the caption, when present) isn't accessible to certain kinds of AT. (Note: I'm currently unable to access a screen reader on this machine, so I could be wrong about this! Basing this on a.) my understanding of role="img" being treated as a replaced element and b.) this note on MDN, but I'd be happy to be proven wrong.

Switching the title to aria-label would make the image's text alternative more accessible, but might not address how role="img" (potentially) complicates access to the internal figcaption. It might be worth refactoring this component to remove the role, inline the image, and allow direct access to both an alt="" attribute and the figure's figcaption.

Steps to reproduce the behavior

This issue is done when

@mitogi mitogi self-assigned this Sep 3, 2024
@mitogi mitogi removed their assignment Sep 16, 2024
@nateborr nateborr assigned nateborr and unassigned nateborr Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants