Skip to content

Commit

Permalink
Use strtok() since only the first instance of auto is considered
Browse files Browse the repository at this point in the history
Co-authored-by: dmsnell <[email protected]>
  • Loading branch information
westonruter and dmsnell authored Aug 9, 2024
1 parent 644cef5 commit 18f00cc
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions plugins/auto-sizes/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,8 @@ function auto_sizes_update_content_img_tag( $html ): string {
* @return bool True if the 'auto' keyword is present, false otherwise.
*/
function auto_sizes_attribute_includes_valid_auto( string $sizes_attr ): bool {
$parts = preg_split( '/\s*,\s*/', strtolower( trim( $sizes_attr ) ) );
if ( ! is_array( $parts ) || ! isset( $parts[0] ) ) {
return false;
}

return 'auto' === $parts[0];
$token = strtok( strtolower( $sizes_attr ), ',' );
return false !== $token && 'auto' === trim( $token, " \t\f\r\n" );
}

/**
Expand Down

0 comments on commit 18f00cc

Please sign in to comment.