mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 14:35:07 +00:00
Pass the requested size to 'wp_get_attachment_image_attributes' filter.
props mattheu. fixes #29869. Built from https://develop.svn.wordpress.org/trunk@29836 git-svn-id: http://core.svn.wordpress.org/trunk@29600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f98106769d
commit
d769e29279
@ -699,12 +699,14 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
|
||||
if ( $image ) {
|
||||
list($src, $width, $height) = $image;
|
||||
$hwstring = image_hwstring($width, $height);
|
||||
if ( is_array($size) )
|
||||
$size = join('x', $size);
|
||||
$size_class = $size;
|
||||
if ( is_array( $size_class ) ) {
|
||||
$size_class = join( 'x', $size_class );
|
||||
}
|
||||
$attachment = get_post($attachment_id);
|
||||
$default_attr = array(
|
||||
'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
|
||||
);
|
||||
if ( empty($default_attr['alt']) )
|
||||
@ -719,10 +721,11 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param mixed $attr Attributes for the image markup.
|
||||
* @param int $attachment Image attachment post.
|
||||
* @param array $attr Attributes for the image markup.
|
||||
* @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 );
|
||||
$html = rtrim("<img $hwstring");
|
||||
foreach ( $attr as $name => $value ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user