Make WordPress Core

Changeset 12035


Ignore:
Timestamp:
10/15/2009 12:31:48 PM (17 years ago)
Author:
markjaquith
Message:

Allow theme devs to change attrs (like CSS class) of thumbnail images. props scribu. see #10928

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r12027 r12035  
    528528 * @return string HTML img element or empty string on failure.
    529529 */
    530 function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false) {
     530function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '') {
    531531
    532532        $html = '';
    … …  
    538538                        $size = join('x', $size);
    539539                $attachment =& get_post($attachment_id);
    540                 $attr = array(
     540                $default_attr = array(
    541541                        'src'   => $src,
    542542                        'class' => "attachment-$size",
    543543                        'alt'   => trim(strip_tags( $attachment->post_excerpt )),
    544544                        'title' => trim(strip_tags( $attachment->post_title )),
    545                         );
     545                );
     546                $attr = wp_parse_args($attr, $default_attr);
    546547                $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment );
    547548                $attr = array_map( 'esc_attr', $attr );
  • trunk/wp-includes/post-template.php

    r12019 r12035  
    910910}
    911911
    912 function the_post_image( $size = 'thumbnail' ) {
    913         echo get_the_post_image( $size );
    914 }
    915 
    916 function get_the_post_image( $size = 'thumbnail', $post_id = NULL ) {
     912function the_post_image( $size = 'thumbnail', $attr = '' ) {
     913        echo get_the_post_image( NULL, $size, $attr );
     914}
     915
     916function get_the_post_image( $post_id = NULL, $size = 'thumbnail', $attr = '' ) {
    917917        global $id;
    918918        $post_id = ( NULL === $post_id ) ? $id : $post_id;
    … …  
    921921        if ( $post_image_id ) {
    922922                do_action( 'begin_fetch_post_image_html', $post_id, $post_image_id, $size ); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
    923                 $html = wp_get_attachment_image( $post_image_id, $size );
     923                $html = wp_get_attachment_image( $post_image_id, $size, false, $attr );
    924924                do_action( 'end_fetch_post_image_html', $post_id, $post_image_id, $size );
    925925        } else {
Note: See TracChangeset for help on using the changeset viewer.