Changeset 56690 for trunk/src/wp-includes/deprecated.php
- Timestamp:
- 09/25/2023 10:37:00 PM (2 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/deprecated.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/deprecated.php
r56682 r56690 5995 5995 update_option( 'https_detection_errors', $support_errors ); 5996 5996 } 5997 5998 /** 5999 * Adds `decoding` attribute to an `img` HTML tag. 6000 * 6001 * The `decoding` attribute allows developers to indicate whether the 6002 * browser can decode the image off the main thread (`async`), on the 6003 * main thread (`sync`) or as determined by the browser (`auto`). 6004 * 6005 * By default WordPress adds `decoding="async"` to images but developers 6006 * can use the {@see 'wp_img_tag_add_decoding_attr'} filter to modify this 6007 * to remove the attribute or set it to another accepted value. 6008 * 6009 * @since 6.1.0 6010 * @deprecated 6.4.0 Use wp_img_tag_add_loading_optimization_attrs() instead. 6011 * @see wp_img_tag_add_loading_optimization_attrs() 6012 * 6013 * @param string $image The HTML `img` tag where the attribute should be added. 6014 * @param string $context Additional context to pass to the filters. 6015 * @return string Converted `img` tag with `decoding` attribute added. 6016 */ 6017 function wp_img_tag_add_decoding_attr( $image, $context ) { 6018 _deprecated_function( __FUNCTION__, '6.4.0', 'wp_img_tag_add_loading_optimization_attrs()' ); 6019 6020 /* 6021 * Only apply the decoding attribute to images that have a src attribute that 6022 * starts with a double quote, ensuring escaped JSON is also excluded. 6023 */ 6024 if ( ! str_contains( $image, ' src="' ) ) { 6025 return $image; 6026 } 6027 6028 /** This action is documented in wp-includes/media.php */ 6029 $value = apply_filters( 'wp_img_tag_add_decoding_attr', 'async', $image, $context ); 6030 6031 if ( in_array( $value, array( 'async', 'sync', 'auto' ), true ) ) { 6032 $image = str_replace( '<img ', '<img decoding="' . esc_attr( $value ) . '" ', $image ); 6033 } 6034 6035 return $image; 6036 }
Note: See TracChangeset
for help on using the changeset viewer.