[wp-trac] [WordPress Trac] #47687: Use alt tags for gallery images in editor

WordPress Trac noreply at wordpress.org
Thu Jul 11 21:39:17 UTC 2019


#47687: Use alt tags for gallery images in editor
-------------------------------------------+-----------------------------
 Reporter:  yarnboy                        |      Owner:  (none)
     Type:  enhancement                    |     Status:  new
 Priority:  normal                         |  Milestone:  Awaiting Review
Component:  Media                          |    Version:  5.2.2
 Severity:  normal                         |   Keywords:
  Focuses:  accessibility, administration  |
-------------------------------------------+-----------------------------
 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
                                                                 }}" />
                                                         <# } #>


 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47687>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list