函数原型
gd_edit_image_support( string $mime_type ): bool
函数描述
Check if the installed version of GD supports particular image type
是否弃用
Warning: This function has been deprecated. Use wp_image_editor_supports() instead.
函数参数
-
$mime_type
string
Required
函数返回值
bool
函数位置
File: wp-includes/deprecated.php.
函数源码
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;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.5.0 | Use wp_image_editor_supports() |
| 2.9.0 | Introduced. |

