@@ -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 );
550550if  ( $ image  ) {
551551list ($ src , $ width , $ height ) = $ image ;
552- $ hwstring  = image_hwstring ($ width , $ height );
553552if  ( 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
563563if  ( 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 " );
570574foreach  ( $ attr  as  $ name  => $ value  ) {
571575$ html  .= "  $ name= "  . '" '  . $ value  . '" ' ;
572576}
0 commit comments