Changeset 50684
- Timestamp:
- 04/07/2021 01:50:59 AM (4 years ago)
- Location:
- branches/5.7
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.7
- Property svn:mergeinfo changed
/trunk merged: 50682-50683
- Property svn:mergeinfo changed
-
branches/5.7/src/wp-includes/media.php
r50662 r50684 1870 1870 */ 1871 1871 function wp_img_tag_add_loading_attr( $image, $context ) { 1872 // Images should have source and dimension attributes for the `loading` attribute to be added. 1873 if ( false === strpos( $image, ' src="' ) || false === strpos( $image, ' width="' ) || false === strpos( $image, ' height="' ) ) { 1874 return $image; 1875 } 1876 1872 1877 /** 1873 1878 * Filters the `loading` attribute value to add to an image. Default `lazy`. … … 1890 1895 } 1891 1896 1892 // Images should have source and dimension attributes for the `loading` attribute to be added.1893 if ( false === strpos( $image, ' src="' ) || false === strpos( $image, ' width="' ) || false === strpos( $image, ' height="' ) ) {1894 return $image;1895 }1896 1897 1897 return str_replace( '<img', '<img loading="' . esc_attr( $value ) . '"', $image ); 1898 1898 } … … 1990 1990 */ 1991 1991 function wp_iframe_tag_add_loading_attr( $iframe, $context ) { 1992 // Iframes with fallback content (see `wp_filter_oembed_result()`) should not be lazy-loaded because they are 1993 // visually hidden initially. 1994 if ( false !== strpos( $iframe, ' data-secret="' ) ) { 1995 return $iframe; 1996 } 1997 1998 // Iframes should have source and dimension attributes for the `loading` attribute to be added. 1999 if ( false === strpos( $iframe, ' src="' ) || false === strpos( $iframe, ' width="' ) || false === strpos( $iframe, ' height="' ) ) { 2000 return $iframe; 2001 } 2002 1992 2003 /** 1993 2004 * Filters the `loading` attribute value to add to an iframe. Default `lazy`. … … 2008 2019 if ( ! in_array( $value, array( 'lazy', 'eager' ), true ) ) { 2009 2020 $value = 'lazy'; 2010 }2011 2012 // Iframes should have source and dimension attributes for the `loading` attribute to be added.2013 if ( false === strpos( $iframe, ' src="' ) || false === strpos( $iframe, ' width="' ) || false === strpos( $iframe, ' height="' ) ) {2014 return $iframe;2015 2021 } 2016 2022 -
branches/5.7/tests/phpunit/tests/media.php
r50132 r50684 2936 2936 $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>'; 2937 2937 add_filter( 'wp_iframe_tag_add_loading_attr', '__return_false' ); 2938 $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); 2939 2940 $this->assertNotContains( ' loading=', $iframe ); 2941 } 2942 2943 /** 2944 * @ticket 52768 2945 */ 2946 function test_wp_iframe_tag_add_loading_attr_skip_wp_embed() { 2947 $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>'; 2948 $fallback = '<blockquote>Fallback content.</blockquote>'; 2949 $iframe = wp_filter_oembed_result( $fallback . $iframe, (object) array( 'type' => 'rich' ), 'https://www.example.com' ); 2950 $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); 2938 2951 2939 2952 $this->assertNotContains( ' loading=', $iframe );
Note: See TracChangeset
for help on using the changeset viewer.