Skip to content

Conversation

@carolinan
Copy link
Contributor

@carolinan carolinan commented Dec 30, 2022

What?

In #41077 it was reported that when a post or page has no title,
but has a linked featured image, there is no link text. This issue only affects the front, not the editors.

This PR adds an alt attribute to the post featured image if it is linked and the post title is missing.
The new alt text is "Untitled post" followed by the post id.

Why?

The missing link text is an accessibility issue since there is no context for the link.

Testing Instructions

  1. Create a new post but do not add a title.
  2. Add a post featured image block and enable the "Link to post" setting in the block sidebar. Save.
  3. View the single post on the front and confirm that the featured image has the correct alt text.
  4. View a page with a query loop with featured images. Confirm that the featured image for your post has the correct alt text.

Testing Instructions for screen reader users

After creating a new post as described above, go to the front view of the post.
Remember that the post has no title, and depending on the theme template, the single post may display
a featured image above the post content. The image that you want to test is the linked image and it should be the only item in the post content.
Confirm that both the link and the image are announced, followed by "Untitled post number".

Voiceover announces "Visited, link, image, Untitled post 720".

Screenshots or screencast

@carolinan carolinan marked this pull request as ready for review December 30, 2022 13:27
@carolinan carolinan requested a review from ajitbohra as a code owner December 30, 2022 13:27
@carolinan carolinan added [Block] Post Featured Image Affects the Post Featured Image Block [a11y] Labelling labels Dec 30, 2022
Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

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

@carolinan Thanks for the PR. Couple code enhancements below.

@carolinan carolinan added the [Type] Bug An existing feature does not function as intended label Jan 2, 2023
Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

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

This looks good to me, and tests as described 👍

@carolinan carolinan merged commit 45e2f6d into trunk Jan 23, 2023
@carolinan carolinan deleted the update/featured-image-no-post-title branch January 23, 2023 05:51
@github-actions github-actions bot added this to the Gutenberg 15.1 milestone Jan 23, 2023
@priethor priethor added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). and removed [a11y] Labelling labels Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Post Featured Image Affects the Post Featured Image Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants