WP_Image_Editor_GD::supports_mime_type()public staticWP 3.5.0

Checks to see if editor supports the mime-type specified.

Метод класса: WP_Image_Editor_GD{}

Хуков нет.

Возвращает

true|false.

Использование

$result = WP_Image_Editor_GD::supports_mime_type( $mime_type );
$mime_type(строка) (обязательный)
-

Список изменений

С версии 3.5.0 Введена.

Код WP_Image_Editor_GD::supports_mime_type() WP 6.7.1

public static function supports_mime_type( $mime_type ) {
	$image_types = imagetypes();
	switch ( $mime_type ) {
		case 'image/jpeg':
			return ( $image_types & IMG_JPG ) !== 0;
		case 'image/png':
			return ( $image_types & IMG_PNG ) !== 0;
		case 'image/gif':
			return ( $image_types & IMG_GIF ) !== 0;
		case 'image/webp':
			return ( $image_types & IMG_WEBP ) !== 0;
		case 'image/avif':
			return ( $image_types & IMG_AVIF ) !== 0 && function_exists( 'imageavif' );
	}

	return false;
}