From d80685a46bcbdcd6727a3b23950912f5f8b0dee5 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 8 Feb 2014 00:19:29 +0000 Subject: [PATCH] Introduce `has_image_size( $name )`, a utility function that helps avoid loading the `$_wp_additional_image_sizes` global. Props mordauk. Fixes #26951. git-svn-id: https://develop.svn.wordpress.org/trunk@27128 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/media.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 89e642bd3b..b71c0b4d72 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -190,6 +190,20 @@ function add_image_size( $name, $width = 0, $height = 0, $crop = false ) { $_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => (bool) $crop ); } +/** + * Check if an image size exists + * + * @since 3.9.0 + * + * @param string $name The image size name. + * @return bool True if it exists, false if not. + */ +function has_image_size( $name = '' ) { + global $_wp_additional_image_sizes; + + return isset( $_wp_additional_image_sizes[$name] ); +} + /** * Registers an image size for the post thumbnail *