WordPress.org

Make WordPress Core

Changeset 29836


Ignore:
Timestamp:
10/05/2014 05:49:32 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Pass the requested size to 'wp_get_attachment_image_attributes' filter.

props mattheu.
fixes #29869.

File:
1 edited

Legend:

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

    r29776 r29836  
    700700        list($src, $width, $height) = $image;
    701701        $hwstring = image_hwstring($width, $height);
    702         if ( is_array($size) )
    703             $size = join('x', $size);
     702        $size_class = $size;
     703        if ( is_array( $size_class ) ) {
     704            $size_class = join( 'x', $size_class );
     705        }
    704706        $attachment = get_post($attachment_id);
    705707        $default_attr = array(
    706708            'src'   => $src,
    707             'class' => "attachment-$size",
     709            'class' => "attachment-$size_class",
    708710            'alt'   => trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )), // Use Alt field first
    709711        );
     
    720722         * @since 2.8.0
    721723         *
    722          * @param mixed $attr       Attributes for the image markup.
    723          * @param int   $attachment Image attachment post.
     724         * @param array        $attr       Attributes for the image markup.
     725         * @param WP_Post      $attachment Image attachment post.
     726         * @param string|array $size       Requested size.
    724727         */
    725         $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment );
     728        $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );
    726729        $attr = array_map( 'esc_attr', $attr );
    727730        $html = rtrim("<img $hwstring");
Note: See TracChangeset for help on using the changeset viewer.