Opened 7 years ago
Closed 6 years ago
#43137 closed defect (bug) (fixed)
Media widgets: Improve the image and gallery previews accessibility
Reported by: | afercia | Owned by: | afercia |
---|---|---|---|
Milestone: | 5.2 | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Widgets | Keywords: | has-screenshots has-patch |
Focuses: | accessibility | Cc: |
Description (last modified by )
Context: in the front-end, the image alt attribute must describe the purpose of the image or must be empty if the image is not a key part of the content and is purely decorative.
Instead, in the admin screens we're in an editing context. As an user, while authoring content, I need to know what the image is, regardless if the image has or has not an alternative text.
The image widget preview already does something to always provide some info about the image. When the image has no alternative text, it uses an aria-describedby
attribute pointing to a hidden element that contains info about the image filename:
Pretty smart. Without this, the image wouldn't provide any useful information to assistive technologies and users wouldn't have any clue what the image is about. It can be improved a bit, as the proper way to give an accessible name to an image is by using an aria-label
or aria-labelledby
attribute, not an aria-describedby
attribute.
Instead, the preview of the new gallery widget introduced in WordPress 4.9 always prints out an empty alt attribute alt=""
for all the images. Worth reminding images with an empty alt attribute are completely ignored by assistive technologies. When navigating through the preview, the only information provided is the textual content for the "more images" text (it appears only when the gallery contains more than 6 images). Also, each image is within a <dl>
element, that doesn't give any useful information to users:
I'd like to propose to use the same pattern used for the Image preview, and provide some extra info for each image in the gallery. Also, as a user I'd like to know how many images are displayed in the preview. Using an unordered list with each image in a <li>
element would make assistive technologies announce that automatically.
Attachments (2)
Change History (15)
#2
@
7 years ago
Screenshots to illustrate what the patch does. Screen readers are now able to announce the number of items in a gallery preview, the alternative text when present, a meaningful text when the alternative text is not present, and a more useful text instead of just "+2":
to evaluate:
- maybe add some visually hidden text before the previews, e.g. "Image preview" and "Gallery preview"
- is the file name the most useful info to provide? Or maybe the attachment title with fallback to the file name?
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
7 years ago
#5
@
7 years ago
I'd probably go with the attachment title first, and filename second. That way, there's at least the option to override the filename should there be a need to do so (because filenames are pretty dreadful more often than not, sadly).
This ticket was mentioned in Slack in #accessibility by rianrietveld. View the logs.
6 years ago
#8
@
6 years ago
- Keywords needs-refresh added
- Milestone changed from 5.1 to 5.2
Unfortunately we're running out of time for 5.1. This ticket does have a patch though (probably needs a refresh) so punting to 5.2.
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
6 years ago
#12
@
6 years ago
43137.2.diff refreshes the patch, also making phpcs happy.
It's very likely the Widgets page will see substantial changes with the Gutenberg phase 2, but I'm going to commit these changes anyway as they establish good practices that should be followed in any new implementation.
43137.diff is a first pass:
Current image has no alternative text. The file name is: %s
aria-hidden="true"
and expands the "more images" text with an aria-label attribute. Instead of, for example "+3" assistive technologies will announce "Additional images added to this gallery: 3"describedById
variable in the gallery template