gd_edit_image_support

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

WordPress Version: 6.5

/**
 * Check if the installed version of GD supports particular image type
 *
 * @since 2.9.0
 * @deprecated 3.5.0 Use wp_image_editor_supports()
 * @see wp_image_editor_supports()
 *
 * @param string $mime_type
 * @return bool
 */
function gd_edit_image_support($mime_type)
{
    _deprecated_function(__FUNCTION__, '3.5.0', 'wp_image_editor_supports()');
    if (function_exists('imagetypes')) {
        switch ($mime_type) {
            case 'image/jpeg':
                return (imagetypes() & IMG_JPG) != 0;
            case 'image/png':
                return (imagetypes() & IMG_PNG) != 0;
            case 'image/gif':
                return (imagetypes() & IMG_GIF) != 0;
            case 'image/webp':
                return (imagetypes() & IMG_WEBP) != 0;
            case 'image/avif':
                return (imagetypes() & IMG_AVIF) != 0;
        }
    } else {
        switch ($mime_type) {
            case 'image/jpeg':
                return function_exists('imagecreatefromjpeg');
            case 'image/png':
                return function_exists('imagecreatefrompng');
            case 'image/gif':
                return function_exists('imagecreatefromgif');
            case 'image/webp':
                return function_exists('imagecreatefromwebp');
            case 'image/avif':
                return function_exists('imagecreatefromavif');
        }
    }
    return false;
}

WordPress Version: 5.8

/**
 * Check if the installed version of GD supports particular image type
 *
 * @since 2.9.0
 * @deprecated 3.5.0 Use wp_image_editor_supports()
 * @see wp_image_editor_supports()
 *
 * @param string $mime_type
 * @return bool
 */
function gd_edit_image_support($mime_type)
{
    _deprecated_function(__FUNCTION__, '3.5.0', 'wp_image_editor_supports()');
    if (function_exists('imagetypes')) {
        switch ($mime_type) {
            case 'image/jpeg':
                return (imagetypes() & IMG_JPG) != 0;
            case 'image/png':
                return (imagetypes() & IMG_PNG) != 0;
            case 'image/gif':
                return (imagetypes() & IMG_GIF) != 0;
            case 'image/webp':
                return (imagetypes() & IMG_WEBP) != 0;
        }
    } else {
        switch ($mime_type) {
            case 'image/jpeg':
                return function_exists('imagecreatefromjpeg');
            case 'image/png':
                return function_exists('imagecreatefrompng');
            case 'image/gif':
                return function_exists('imagecreatefromgif');
            case 'image/webp':
                return function_exists('imagecreatefromwebp');
        }
    }
    return false;
}

WordPress Version: 4.6

/**
 * Check if the installed version of GD supports particular image type
 *
 * @since 2.9.0
 * @deprecated 3.5.0 Use wp_image_editor_supports()
 * @see wp_image_editor_supports()
 *
 * @param string $mime_type
 * @return bool
 */
function gd_edit_image_support($mime_type)
{
    _deprecated_function(__FUNCTION__, '3.5.0', 'wp_image_editor_supports()');
    if (function_exists('imagetypes')) {
        switch ($mime_type) {
            case 'image/jpeg':
                return (imagetypes() & IMG_JPG) != 0;
            case 'image/png':
                return (imagetypes() & IMG_PNG) != 0;
            case 'image/gif':
                return (imagetypes() & IMG_GIF) != 0;
        }
    } else {
        switch ($mime_type) {
            case 'image/jpeg':
                return function_exists('imagecreatefromjpeg');
            case 'image/png':
                return function_exists('imagecreatefrompng');
            case 'image/gif':
                return function_exists('imagecreatefromgif');
        }
    }
    return false;
}

WordPress Version: 4.4

/**
 * Check if the installed version of GD supports particular image type
 *
 * @since 2.9.0
 * @deprecated 3.5.0 Use wp_image_editor_supports()
 * @see wp_image_editor_supports()
 *
 * @param string $mime_type
 * @return bool
 */
function gd_edit_image_support($mime_type)
{
    _deprecated_function(__FUNCTION__, '3.5', 'wp_image_editor_supports()');
    if (function_exists('imagetypes')) {
        switch ($mime_type) {
            case 'image/jpeg':
                return (imagetypes() & IMG_JPG) != 0;
            case 'image/png':
                return (imagetypes() & IMG_PNG) != 0;
            case 'image/gif':
                return (imagetypes() & IMG_GIF) != 0;
        }
    } else {
        switch ($mime_type) {
            case 'image/jpeg':
                return function_exists('imagecreatefromjpeg');
            case 'image/png':
                return function_exists('imagecreatefrompng');
            case 'image/gif':
                return function_exists('imagecreatefromgif');
        }
    }
    return false;
}

WordPress Version: 3.7

/**
 * Check if the installed version of GD supports particular image type
 *
 * @since 2.9.0
 * @deprecated 3.5.0
 * @see wp_image_editor_supports()
 *
 * @param string $mime_type
 * @return bool
 */
function gd_edit_image_support($mime_type)
{
    _deprecated_function(__FUNCTION__, '3.5', 'wp_image_editor_supports()');
    if (function_exists('imagetypes')) {
        switch ($mime_type) {
            case 'image/jpeg':
                return (imagetypes() & IMG_JPG) != 0;
            case 'image/png':
                return (imagetypes() & IMG_PNG) != 0;
            case 'image/gif':
                return (imagetypes() & IMG_GIF) != 0;
        }
    } else {
        switch ($mime_type) {
            case 'image/jpeg':
                return function_exists('imagecreatefromjpeg');
            case 'image/png':
                return function_exists('imagecreatefrompng');
            case 'image/gif':
                return function_exists('imagecreatefromgif');
        }
    }
    return false;
}