Pass the requested size to 'wp_get_attachment_image_attributes' filter.
props mattheu. fixes #29869. git-svn-id: https://develop.svn.wordpress.org/trunk@29836 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d2c8c72e7f
commit
a21e5041dd
|
@ -699,12 +699,14 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
|
||||||
if ( $image ) {
|
if ( $image ) {
|
||||||
list($src, $width, $height) = $image;
|
list($src, $width, $height) = $image;
|
||||||
$hwstring = image_hwstring($width, $height);
|
$hwstring = image_hwstring($width, $height);
|
||||||
if ( is_array($size) )
|
$size_class = $size;
|
||||||
$size = join('x', $size);
|
if ( is_array( $size_class ) ) {
|
||||||
|
$size_class = join( 'x', $size_class );
|
||||||
|
}
|
||||||
$attachment = get_post($attachment_id);
|
$attachment = get_post($attachment_id);
|
||||||
$default_attr = array(
|
$default_attr = array(
|
||||||
'src' => $src,
|
'src' => $src,
|
||||||
'class' => "attachment-$size",
|
'class' => "attachment-$size_class",
|
||||||
'alt' => trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )), // Use Alt field first
|
'alt' => trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )), // Use Alt field first
|
||||||
);
|
);
|
||||||
if ( empty($default_attr['alt']) )
|
if ( empty($default_attr['alt']) )
|
||||||
|
@ -719,10 +721,11 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*
|
*
|
||||||
* @param mixed $attr Attributes for the image markup.
|
* @param array $attr Attributes for the image markup.
|
||||||
* @param int $attachment Image attachment post.
|
* @param WP_Post $attachment Image attachment post.
|
||||||
|
* @param string|array $size Requested size.
|
||||||
*/
|
*/
|
||||||
$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment );
|
$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );
|
||||||
$attr = array_map( 'esc_attr', $attr );
|
$attr = array_map( 'esc_attr', $attr );
|
||||||
$html = rtrim("<img $hwstring");
|
$html = rtrim("<img $hwstring");
|
||||||
foreach ( $attr as $name => $value ) {
|
foreach ( $attr as $name => $value ) {
|
||||||
|
|
Loading…
Reference in New Issue