Skip to content

Commit

Permalink
Introduce has_image_size( $name ), a utility function that helps av…
Browse files Browse the repository at this point in the history
…oid loading the `$_wp_additional_image_sizes` global.

Props mordauk.
Fixes #26951.


Built from https://develop.svn.wordpress.org/trunk@27128


git-svn-id: http://core.svn.wordpress.org/trunk@26995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
staylor committed Feb 8, 2014
1 parent 03dda3b commit 2610e6d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wp-includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 2610e6d

Please sign in to comment.