wp_sizes_attribute_includes_valid_auto()WP 6.7.0

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

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

No Hooks.

Return

true|false. True if the 'auto' keyword is present, false otherwise.

Usage

wp_sizes_attribute_includes_valid_auto( $sizes_attr ): bool;
$sizes_attr(string) (required)
The 'sizes' attribute value.

Changelog

Since 6.7.0 Introduced.

wp_sizes_attribute_includes_valid_auto() code WP 6.7.1

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" ) );
}