[wp-trac] [WordPress Trac] #11809: Galleries and template tags do not respect alternate text

WordPress Trac wp-trac at lists.automattic.com
Mon Jul 23 19:53:59 UTC 2012


#11809: Galleries and template tags do not respect alternate text
--------------------------+-----------------------------
 Reporter:  doug          |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Media         |     Version:  2.9.1
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |
--------------------------+-----------------------------
Changes (by martythornley):

 * cc: marty@… (added)


Comment:

 I was testing this to look at adding a patch but it seems to have been
 fixed already in trunk. I couldn't find another ticket that deals with it
 but if you look at the wp_get_attachment_image() function, it already has
 the alt info added with a couple fallbacks. It adds the alt correctly to
 the gallery code correctly as far as I could tell.
 {{{
 $default_attr = array(
         'src'   => $src,
         'class' => "attachment-$size",
         'alt'   => trim(strip_tags( get_post_meta($attachment_id,
 '_wp_attachment_image_alt', true) )), // Use Alt field first
         'title' => trim(strip_tags( $attachment->post_title )),
 );
 if ( empty($default_attr['alt']) )
         $default_attr['alt'] = trim(strip_tags( $attachment->post_excerpt
 )); // If not, Use the Caption
 if ( empty($default_attr['alt']) )
         $default_attr['alt'] = trim(strip_tags( $attachment->post_title
 )); // Finally, use the title
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11809#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list