wp_img_tag_add_auto_sizes
Filter HookDescription
Prints a CSS rule to fix potential visual issues with images using `sizes=auto`. 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.Hook Information
| File Location |
wp-includes/media.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 2081 |
Hook Parameters
This hook doesn't accept any parameters.
Usage Examples
Basic Usage
<?php
// Hook into wp_img_tag_add_auto_sizes
add_filter('wp_img_tag_add_auto_sizes', 'my_custom_filter');
function my_custom_filter() {
// Your custom filtering logic here
return 'modified_value';
}
Source Code Context
wp-includes/media.php:2081
- How this hook is used in WordPress core
<?php
2076 * @see https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size
2077 * @see https://core.trac.wordpress.org/ticket/62413
2078 */
2079 function wp_print_auto_sizes_contain_css_fix() {
2080 /** This filter is documented in wp-includes/media.php */
2081 $add_auto_sizes = apply_filters( 'wp_img_tag_add_auto_sizes', true );
2082 if ( ! $add_auto_sizes ) {
2083 return;
2084 }
2085
2086 ?>
PHP Documentation
<?php
/**
* Prints a CSS rule to fix potential visual issues with images using `sizes=auto`.
*
* 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.
*
* @since 6.7.1
* @see https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size
* @see https://core.trac.wordpress.org/ticket/62413
*/
Quick Info
- Hook Type: Filter
- Parameters: 0
- File: wp-includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.