Checks if an image size exists.
Parameters
$name
stringrequired- The image size to check.
Source
function has_image_size( $name ) {
$sizes = wp_get_additional_image_sizes();
return isset( $sizes[ $name ] );
}
Changelog
Version | Description |
---|---|
3.9.0 | Introduced. |
This function only checks for image sizes that are registered via the
add_image_size()
function, core image sizes, namely small, medium, medium_large and large, are not considered. Hence, checking for a core image size usinghas_image_size()
will always return FALSE.In a theme’s functions.php file combined with
remove_image_size()
: