gd_edit_image_support

函式
gd_edit_image_support ( $mime_type )
引數
  • (string) $mime_type
    Required:
返回值
  • (bool)
相關
  • wp_image_editor_supports()
定義位置
相關方法
get_theme_supportadd_theme_supportget_image_tag_add_default_theme_supportswp_timezone_supported
引入
2.9.0
棄用
3.5.0

gd_edit_image_support: 這個函式用來確定伺服器是否支援GD庫,GD庫用於在WordPress中編輯影象。

檢查所安裝的GD版本是否支援特定的影象型別。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >