Title: wp_img_tag_add_auto_sizes
Published: February 24, 2026
Last modified: August 20, 2026

---

# apply_filters( ‘wp_img_tag_add_auto_sizes’, boolean $enabled )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#wp--skip-link--target)

Filters whether auto-sizes for lazy loaded images is enabled.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#parameters)󠁿

 `$enabled`boolean

Whether auto-sizes for lazy loaded images is enabled.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#source)󠁿

    ```php
    if ( ! apply_filters( 'wp_img_tag_add_auto_sizes', true ) ) {
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/media.php#L2125)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/media.php#L2125-L2125)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_print_auto_sizes_contain_css_fix()](https://developer.wordpress.org/reference/functions/wp_print_auto_sizes_contain_css_fix/)`wp-includes/deprecated.php` |

Prints a CSS rule to fix potential visual issues with images using `sizes=auto`.

  | 
| [wp_img_tag_add_auto_sizes()](https://developer.wordpress.org/reference/functions/wp_img_tag_add_auto_sizes/)`wp-includes/media.php` |

Adds ‘auto’ to the sizes attribute to the image, if the image is lazy loaded and does not already include it.

  | 
| [wp_enqueue_img_auto_sizes_contain_css_fix()](https://developer.wordpress.org/reference/functions/wp_enqueue_img_auto_sizes_contain_css_fix/)`wp-includes/media.php` |

Enqueues a CSS rule to fix potential visual issues with images using `sizes=auto`.

  | 
| [wp_get_attachment_image()](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/)`wp-includes/media.php` |

Gets an HTML img element representing an image attachment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.7.1](https://developer.wordpress.org/reference/since/6.7.1/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_img_tag_add_auto_sizes%2F)
before being able to contribute a note or feedback.