WordPress.org

Make WordPress Core

Changeset 14145


Ignore:
Timestamp:
04/18/10 08:52:18 (5 years ago)
Author:
dd32
Message:

Use Alt Text for Image alt caption (Falling back to Caption, and finally title) in wp_get_attachment_image() and subsequently, WordPress Galleries. Props kallewangstedt for initial patch. Fixes #11846

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r14139 r14145  
    610610            'src'   => $src, 
    611611            'class' => "attachment-$size", 
    612             'alt'   => trim(strip_tags( $attachment->post_excerpt )), 
     612            'alt'   => trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )), // Use Alt field first 
    613613            'title' => trim(strip_tags( $attachment->post_title )), 
    614614        ); 
     615        if ( empty($default_attr['alt']) ) 
     616            $default_attr['alt'] = trim(strip_tags( $attachment->post_excerpt )); // If not, Use the Caption 
     617        if ( empty($default_attr['alt']) ) 
     618            $default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title 
     619 
    615620        $attr = wp_parse_args($attr, $default_attr); 
    616621        $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment ); 
Note: See TracChangeset for help on using the changeset viewer.