Prints a CSS rule to fix potential visual issues with images using sizes=auto.
Description
This rule overrides the similar rule in the default user agent stylesheet, to avoid images that use e.g.width: auto or width: fit-content to appear smaller.
See also
Source
function wp_print_auto_sizes_contain_css_fix() {
_deprecated_function( __FUNCTION__, '6.9.0', 'wp_enqueue_img_auto_sizes_contain_css_fix' );
/** This filter is documented in wp-includes/media.php */
$add_auto_sizes = apply_filters( 'wp_img_tag_add_auto_sizes', true );
if ( ! $add_auto_sizes ) {
return;
}
?>
<style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>
<?php
}
Hooks
- apply_filters( ‘wp_img_tag_add_auto_sizes’,
boolean $enabled ) Filters whether auto-sizes for lazy loaded images is enabled.
Changelog
| Version | Description |
|---|---|
| 6.9.0 | Deprecated. Use wp_enqueue_img_auto_sizes_contain_css_fix() instead. |
| 6.7.1 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.