Opened 7 years ago
Closed 7 years ago
#47687 closed enhancement (fixed)
Use alt tags for gallery images in editor
| Reported by: | yarnboy | Owned by: | afercia |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.2.3 |
| Component: | Media | Version: | 5.2.2 |
| Severity: | normal | Keywords: | has-patch needs-testing fixed-major |
| Cc: | Focuses: | accessibility, administration |
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
@
7 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
@
7 years ago
- Keywords commit added
- Milestone Awaiting Review → 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
@
7 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
@
7 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!
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
7 years ago
#9
@
7 years ago
- Keywords needs-testing fixed-major added
- Milestone 5.3 → 5.2.3
- Resolution fixed
- Status closed → 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
@
7 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
@
7 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I have included alt tag text in the WordPress editor for the Gallery images