WP_Image_Editor::get_mime_type()protected staticWP 3.5.0

Returns first matched mime-type from extension, as mapped from wp_get_mime_types()

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

Хуков нет.

Возвращает

Строку|false.

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

$result = WP_Image_Editor::get_mime_type( $extension );
$extension(строка)
-
По умолчанию: null

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

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

Код WP_Image_Editor::get_mime_type() WP 6.1.1

protected static function get_mime_type( $extension = null ) {
	if ( ! $extension ) {
		return false;
	}

	$mime_types = wp_get_mime_types();
	$extensions = array_keys( $mime_types );

	foreach ( $extensions as $_extension ) {
		if ( preg_match( "/{$extension}/i", $_extension ) ) {
			return $mime_types[ $_extension ];
		}
	}

	return false;
}