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

Describe the image in the featured image preview #14416

Closed
afercia opened this issue Mar 13, 2019 · 6 comments · Fixed by #24888
Closed

Describe the image in the featured image preview #14416

afercia opened this issue Mar 13, 2019 · 6 comments · Fixed by #24888
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Mar 13, 2019

When a featured image is set, a preview is displayed within a button. Pressing the preview button opens the media modal to replace the image.

The preview button has an aria-label="Edit or update the image" which gives the correct information to assistive technology users.

However, there's no indication of what the set image is. All users need to know which image is set, including assistive technology users.

In this case, it's not possible to use the alt attribute because the entire content of the preview button is overridden by the aria-label="Edit or update the image". A possible solution is an aria-describedby attribute on the button to target a visually hidden description.

The description should contain some meaningful text:

  • when the image has an alt text: Current image: altText
  • when the image doesn't have an alt text: The current image has no alternative text. The file name is: fileName

Note: the second text is the same currently used in core for the media widgets.

This way, the whole preview would be announced, for example, this way:

  • Edit or update the image (brief pause) Current image: My awesome image
  • Edit or update the image (brief pause) The current image has no alternative text. The file name is: DSC-345678.jpg
@afercia afercia 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). labels Mar 13, 2019
@gziolo gziolo added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Mar 22, 2019
@Jackie6
Copy link
Contributor

Jackie6 commented Mar 23, 2019

Hi @afercia I found the default alt text of the image is empty string. Even if I add alt text in the image-modal, the html still shows alt is empty (see below image)

<img src={ mediaSourceUrl } alt="" />

image

@afercia
Copy link
Contributor Author

afercia commented Mar 23, 2019

@Jackie6 yes, but the alt text wouldn't help in this case. As mentioned above, the entire content is overridden by the aria-label on the button. We need to put some meaningful text in the aria-label.

<Button
className={ ! featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview' }
onClick={ open }
aria-label={ ! featuredImageId ? null : __( 'Edit or update the image' ) }>
{ !! featuredImageId && media &&
<ResponsiveWrapper
naturalWidth={ mediaWidth }
naturalHeight={ mediaHeight }
>
<img src={ mediaSourceUrl } alt="" />
</ResponsiveWrapper>
}
{ !! featuredImageId && ! media && <Spinner /> }
{ ! featuredImageId && ( postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL ) }
</Button>

@Jackie6
Copy link
Contributor

Jackie6 commented Mar 23, 2019

@afercia Hi Andrea, I have created a pull request to fix the issue. I am not sure what is the best way to get the file name of the image. Because in the API documentation, there is no name or tile. So I just use the basename function to extract the filename from the url of the image.

@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Apr 10, 2019
jorgefilipecosta added a commit that referenced this issue Apr 11, 2019
## Description
Related in #14416 we have a similar issue but for the featured image that issue is being addressed on #14593.

Here the solution is not as perfect, as we don't have the alt text of the poster image only the URL was saved in the attributes.

## How has this been tested?
I used the voice over utility and I checked that a descriptive message is announced after the select/replace poster image button gains focus.
mchowning pushed a commit to mchowning/gutenberg that referenced this issue Apr 15, 2019
…14752)

## Description
Related in WordPress#14416 we have a similar issue but for the featured image that issue is being addressed on WordPress#14593.

Here the solution is not as perfect, as we don't have the alt text of the poster image only the URL was saved in the attributes.

## How has this been tested?
I used the voice over utility and I checked that a descriptive message is announced after the select/replace poster image button gains focus.
@afercia
Copy link
Contributor Author

afercia commented Mar 20, 2020

This was reported a few days ago also on the WordPress Trac. See https://core.trac.wordpress.org/ticket/49651

@aristath
Copy link
Member

Just opened a PR for this on #24888 👍

@afercia
Copy link
Contributor Author

afercia commented Sep 6, 2020

The related Trac ticket was one of the tickets the accessibility team milestoned for WordPress 5.5. The accessibility team would need some help (we did ask for help) to help this issue move on 🙂 Setting the milestone to WordPress 5.6. for visibility.

@afercia afercia added this to the WordPress 5.6 milestone Sep 6, 2020
@tellthemachines tellthemachines removed this from the WordPress 5.6 milestone Sep 16, 2020
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). Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
5 participants