is_gd_image

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

WordPress Version: 6.3

/**
 * Determines whether the value is an acceptable type for GD image functions.
 *
 * In PHP 8.0, the GD extension uses GdImage objects for its data structures.
 * This function checks if the passed value is either a GdImage object instance
 * or a resource of type `gd`. Any other type will return false.
 *
 * @since 5.6.0
 *
 * @param resource|GdImage|false $image A value to check the type for.
 * @return bool True if `$image` is either a GD image resource or a GdImage instance,
 *              false otherwise.
 */
function is_gd_image($image)
{
    if ($image instanceof GdImage || is_resource($image) && 'gd' === get_resource_type($image)) {
        return true;
    }
    return false;
}

WordPress Version: 5.6

/**
 * Determines whether the value is an acceptable type for GD image functions.
 *
 * In PHP 8.0, the GD extension uses GdImage objects for its data structures.
 * This function checks if the passed value is either a resource of type `gd`
 * or a GdImage object instance. Any other type will return false.
 *
 * @since 5.6.0
 *
 * @param resource|GdImage|false $image A value to check the type for.
 * @return bool True if $image is either a GD image resource or GdImage instance,
 *              false otherwise.
 */
function is_gd_image($image)
{
    if (is_resource($image) && 'gd' === get_resource_type($image) || is_object($image) && $image instanceof GdImage) {
        return true;
    }
    return false;
}