Title: wp_sizes_attribute_includes_valid_auto
Published: February 24, 2026

---

# wp_sizes_attribute_includes_valid_auto( string $sizes_attr ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#changelog)

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

Checks whether the given ‘sizes’ attribute includes the ‘auto’ keyword as the first
item in the list.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#description)󠁿

Per the HTML spec, if present it must be the first entry.

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

 `$sizes_attr`stringrequired

The `'sizes'` attribute value.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#return)󠁿

 bool True if the `'auto'` keyword is present, false otherwise.

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

    ```php
    function wp_sizes_attribute_includes_valid_auto( string $sizes_attr ): bool {
    	list( $first_size ) = explode( ',', $sizes_attr, 2 );
    	return 'auto' === strtolower( trim( $first_size, " \t\f\r\n" ) );
    }
    ```

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

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

| Used by | Description | 
| [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_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/functions/wp_sizes_attribute_includes_valid_auto/?output_format=md#changelog)󠁿

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

## User Contributed Notes

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