diff --git a/wp-includes/media.php b/wp-includes/media.php index 11815e65fa..f8b0f9c1b1 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -5662,7 +5662,7 @@ function wp_get_loading_optimization_attributes( $tag_name, $attr, $context ) { } // Special handling for programmatically created image tags. - if ( 'the_post_thumbnail' === $context || 'wp_get_attachment_image' === $context ) { + if ( 'the_post_thumbnail' === $context || 'wp_get_attachment_image' === $context || 'widget_media_image' === $context ) { /* * Skip programmatically created images within post content as they need to be handled together with the other * images within the post content. diff --git a/wp-includes/version.php b/wp-includes/version.php index 95fbecadb5..6aa9e9a16e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-beta3-56153'; +$wp_version = '6.3-beta3-56154'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/widgets/class-wp-widget-media-image.php b/wp-includes/widgets/class-wp-widget-media-image.php index 77df8050d8..31a8bef16f 100644 --- a/wp-includes/widgets/class-wp-widget-media-image.php +++ b/wp-includes/widgets/class-wp-widget-media-image.php @@ -239,14 +239,31 @@ class WP_Widget_Media_Image extends WP_Widget_Media { $instance['height'] = ''; } - $image = sprintf( - '%3$s', - esc_attr( $classes ), - esc_url( $instance['url'] ), - esc_attr( $instance['alt'] ), - esc_attr( $instance['width'] ), - esc_attr( $instance['height'] ) + $attr = array( + 'class' => $classes, + 'src' => $instance['url'], + 'alt' => $instance['alt'], + 'width' => $instance['width'], + 'height' => $instance['height'], + 'decoding' => 'async', ); + + $loading_optimization_attr = wp_get_loading_optimization_attributes( + 'img', + $attr, + 'widget_media_image' + ); + + $attr = array_merge( $attr, $loading_optimization_attr ); + + $attr = array_map( 'esc_attr', $attr ); + $image = ' $value ) { + $image .= ' ' . $name . '="' . $value . '"'; + } + + $image .= ' />'; } // End if(). $url = '';