Opened 5 years ago
Closed 5 years ago
#47687 closed enhancement (fixed)
Use alt tags for gallery images in editor
Reported by: | yarnboy | Owned by: | afercia |
---|---|---|---|
Milestone: | 5.2.3 | Priority: | normal |
Severity: | normal | Version: | 5.2.2 |
Component: | Media | Keywords: | has-patch needs-testing fixed-major |
Focuses: | accessibility, administration | Cc: |
Description
Gallery images do not include alt tag text in the WordPress editor. This presents a challenge for accessibility, and also adds a hurdle for writing plugins to force users to use alt tags (which is what I'm trying to do; I work for an institution that prioritizes web accessibility).
The solution to this problem is to make an edit to lines 1294 - 1302 in wp-includes/media-template.php, which currently appears this way:
<# if ( attachment.thumbnail ) { #> <img src="{{ attachment.thumbnail.url }}" data-test="success" width="{{ attachment .thumbnail.width }}" height="{{ attachment.thumbnail.height }}" alt="" /> <# } else { #> <img src="{{ attachment.url }}" data-test="success" alt="" /> <# } #>
And with my suggested edit:
<# if ( attachment.thumbnail ) { #> <img src="{{ attachment.thumbnail.url }}" data-test="success" width="{{ attachment .thumbnail.width }}" height="{{ attachment.thumbnail.height }}" alt="{{ attachment.alt }}" /> <# } else { #> <img src="{{ attachment.url }}" data-test="success" alt="{{ attachment.alt }}" /> <# } #>
Attachments (1)
Change History (14)
#1
@
5 years ago
- Keywords has-patch added
Hello, @yarnboy Thanks for the reported. I have added above patch as per your suggestion. Now alt tag text incleded in the WordPress editor for the Gallery images.
#2
follow-up:
↓ 4
@
5 years ago
- Keywords commit added
- Milestone changed from Awaiting Review to 5.3
@yarnboy @wpboss thanks the report and the patch!
Seems to me it's a good improvement for the Classic Editor. For the new Block Editor (Gutenberg), I see there's one more problem to solve. I'm going to report it on the Gutenberg GitHub repository.
Note for other reviewers: this relates to the alt
attribute of gallery images within the editor.
#3
@
5 years ago
Thanks for the update @afercia.
So, Can I add same patch on https://github.com/WordPress/gutenberg/ or this patch will be auto included there?
#5
@
5 years ago
@wpboss the issue in Gutenberg is similar but the root cause is different, see https://github.com/WordPress/gutenberg/issues/16886. There's the need for a different approach there. If you're comfortable with Gutenberg development, please do feel free to propose a pull request!
#6
@
5 years ago
- Owner set to afercia
- Resolution set to fixed
- Status changed from new to closed
In 45725:
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
5 years ago
#9
@
5 years ago
- Keywords needs-testing fixed-major added
- Milestone changed from 5.3 to 5.2.3
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening this so it can be back-ported to the 5.2 branch.
Adding needs-testing
since we have to check it's ok to land in 5.2.3.
#10
@
5 years ago
Tested on my side against 5.2.2, but unless I'm mistaken [45725] doesn't look to apply cleanly: media-template.php
seems to have some dependancies to previous commits. Otherwise, it's good to go.
#11
@
5 years ago
@afercia any insight into what commit(s) this may depend upon? If we're unsure, then we'll likely move this ticket back to 5.3. to limit risk in 5.2.3.
I have included alt tag text in the WordPress editor for the Gallery images