has_image_size

The timeline below displays how wordpress function has_image_size has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Checks if an image size exists.
 *
 * @since 3.9.0
 *
 * @param string $name The image size to check.
 * @return bool True if the image size exists, false if not.
 */
function has_image_size($name)
{
    $sizes = wp_get_additional_image_sizes();
    return isset($sizes[$name]);
}

WordPress Version: 4.7

/**
 * Check if an image size exists.
 *
 * @since 3.9.0
 *
 * @param string $name The image size to check.
 * @return bool True if the image size exists, false if not.
 */
function has_image_size($name)
{
    $sizes = wp_get_additional_image_sizes();
    return isset($sizes[$name]);
}

WordPress Version: 4.3

/**
 * Check if an image size exists.
 *
 * @since 3.9.0
 *
 * @global array $_wp_additional_image_sizes
 *
 * @param string $name The image size to check.
 * @return bool True if the image size exists, false if not.
 */
function has_image_size($name)
{
    global $_wp_additional_image_sizes;
    return isset($_wp_additional_image_sizes[$name]);
}

WordPress Version: 3.9

/**
 * Check if an image size exists.
 *
 * @since 3.9.0
 *
 * @param string $name The image size to check.
 * @return bool True if the image size exists, false if not.
 */
function has_image_size($name)
{
    global $_wp_additional_image_sizes;
    return isset($_wp_additional_image_sizes[$name]);
}