mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Media: Ensure that the image widget supports loading optimization attributes.
This changeset adds support for loading optimization attributes such as `loading="lazy"` and `fetchpriority="high"` to the image widget. A new context `widget_media_image` is introduced for that purpose. Props spacedmonkey, thekt12, mukesh27, westonruter. Fixes #58704. See #58235. git-svn-id: https://develop.svn.wordpress.org/trunk@56154 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4191,7 +4191,7 @@ EOF;
|
||||
*
|
||||
* @expectedDeprecated wp_get_loading_attr_default
|
||||
*
|
||||
* @dataProvider data_special_contexts_for_the_content
|
||||
* @dataProvider data_special_contexts_for_the_content_wp_get_loading_attr_default
|
||||
*
|
||||
* @param string $context Context for the element for which the `loading` attribute value is requested.
|
||||
*/
|
||||
@@ -4208,7 +4208,7 @@ EOF;
|
||||
*
|
||||
* @expectedDeprecated wp_get_loading_attr_default
|
||||
*
|
||||
* @dataProvider data_special_contexts_for_the_content
|
||||
* @dataProvider data_special_contexts_for_the_content_wp_get_loading_attr_default
|
||||
*
|
||||
* @param string $context Context for the element for which the `loading` attribute value is requested.
|
||||
*/
|
||||
@@ -4233,6 +4233,19 @@ EOF;
|
||||
* @return array[]
|
||||
*/
|
||||
public function data_special_contexts_for_the_content() {
|
||||
return array(
|
||||
'widget_media_image' => array( 'context' => 'widget_media_image' ),
|
||||
'the_post_thumbnail' => array( 'context' => 'the_post_thumbnail' ),
|
||||
'wp_get_attachment_image' => array( 'context' => 'wp_get_attachment_image' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function data_special_contexts_for_the_content_wp_get_loading_attr_default() {
|
||||
return array(
|
||||
'the_post_thumbnail' => array( 'context' => 'the_post_thumbnail' ),
|
||||
'wp_get_attachment_image' => array( 'context' => 'wp_get_attachment_image' ),
|
||||
|
||||
@@ -494,6 +494,8 @@ class Tests_Widgets_wpWidgetMediaImage extends WP_UnitTestCase {
|
||||
|
||||
// Custom image class.
|
||||
$this->assertStringContainsString( 'src="http://example.org/url/to/image.jpg"', $output );
|
||||
$this->assertStringContainsString( 'decoding="async"', $output );
|
||||
$this->assertStringContainsString( 'loading="lazy"', $output );
|
||||
|
||||
// Link settings.
|
||||
ob_start();
|
||||
|
||||
Reference in New Issue
Block a user