wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema
wp_img_tag_add_decoding_attr is deprecated since version 6.4.0!
Alternative: Ver página de detalhe para wp_img_tag_add_loading_optimization_attrs »" href="https://pt.wpseek.com/function/wp_img_tag_add_loading_optimization_attrs/">wp_img_tag_add_loading_optimization_attrs()
Alternative: Ver página de detalhe para wp_img_tag_add_loading_optimization_attrs »" href="https://pt.wpseek.com/function/wp_img_tag_add_loading_optimization_attrs/">wp_img_tag_add_loading_optimization_attrs()
wp_img_tag_add_decoding_attr › WordPress Function
Desde6.1.0
Obsoleto6.4.0
› wp_img_tag_add_decoding_attr ( $image, $context )
| Parâmetros: (2) |
|
| Ver: | |
| Retorna: |
|
| Definido em: |
|
| Codex: |
Adds `decoding` attribute to an `img` HTML tag.
Thedecoding attribute allows developers to indicate whether the
browser can decode the image off the main thread (async), on the
main thread (sync) or as determined by the browser (auto).
By default WordPress adds decoding="async" to images but developers
can use the {@see 'wp_img_tag_add_decoding_attr'} filter to modify this
to remove the attribute or set it to another accepted value.Fonte
function wp_img_tag_add_decoding_attr( $image, $context ) {
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_img_tag_add_loading_optimization_attrs()' );
/*
* Only apply the decoding attribute to images that have a src attribute that
* starts with a double quote, ensuring escaped JSON is also excluded.
*/
if ( ! str_contains( $image, ' src="' ) ) {
return $image;
}
/** This action is documented in wp-includes/media.php */
$value = apply_filters( 'wp_img_tag_add_decoding_attr', 'async', $image, $context );
if ( in_array( $value, array( 'async', 'sync', 'auto' ), true ) ) {
$image = str_replace( '<img ', '<img decoding="' . esc_attr( $value ) . '" ', $image );
}
return $image;
}