wp_img_tag_add_decoding_attr
Filters the decoding attribute value to add to an image. Default async.
Returning a falsey value will omit the attribute.
Usage
add_filter( 'wp_img_tag_add_decoding_attr', 'wp_kama_img_tag_add_decoding_attr_filter', 10, 3 ); /** * Function for `wp_img_tag_add_decoding_attr` filter-hook. * * @param string|false|null $value The `decoding` attribute value. Returning a falsey value will result in the attribute being omitted for the image. Otherwise, it may be: 'async', 'sync', or 'auto'. * @param string $image The HTML `img` tag to be filtered. * @param string $context Additional context about how the function was called or where the img tag is. * * @return string|false|null */ function wp_kama_img_tag_add_decoding_attr_filter( $value, $image, $context ){ // filter... return $value; }
- $value(string|false|null)
- The decoding attribute value. Returning a falsey value will result in the attribute being omitted for the image. Otherwise, it may be: 'async', 'sync', or 'auto'.
Default: false - $image(string)
- The HTML img tag to be filtered.
- $context(string)
- Additional context about how the function was called or where the img tag is.
Changelog
Since 6.1.0 | Introduced. |
Where the hook is called
wp_img_tag_add_decoding_attr
wp_img_tag_add_decoding_attr
wp-includes/media.php 2140-2145
$filtered_decoding_attr = apply_filters( 'wp_img_tag_add_decoding_attr', isset( $optimization_attrs['decoding'] ) ? $optimization_attrs['decoding'] : false, $image, $context );
wp-includes/deprecated.php 6046
$value = apply_filters( 'wp_img_tag_add_decoding_attr', 'async', $image, $context );