Skip to content

Commit a56e911

Browse files
committed
1 parent 7ccc34c commit a56e911

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

wp-includes/media.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,9 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
549549
$image = wp_get_attachment_image_src($attachment_id, $size, $icon);
550550
if ( $image ) {
551551
list($src, $width, $height) = $image;
552-
$hwstring = image_hwstring($width, $height);
553552
if ( is_array($size) )
554553
$size = join('x', $size);
554+
555555
$attachment = get_post($attachment_id);
556556
$default_attr = array(
557557
'src'=> $src,
@@ -563,10 +563,14 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
563563
if ( empty($default_attr['alt']) )
564564
$default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title
565565

566-
$attr = wp_parse_args($attr, $default_attr);
566+
if($width) $default_attr['width'] = (int) $width;
567+
if($height) $default_attr['height'] = (int) $height;
568+
569+
$attr = wp_parse_args( $attr, $default_attr );
570+
567571
$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment );
568572
$attr = array_map( 'esc_attr', $attr );
569-
$html = rtrim("<img $hwstring");
573+
$html = rtrim("<img");
570574
foreach ( $attr as $name => $value ) {
571575
$html .= " $name=" . '"' . $value . '"';
572576
}

0 commit comments

Comments
 (0)