GC_Image_Editor::get_mime_type()

最后更新于:2021-11-27 23:35:04

GC_Image_Editor::get_mime_type( string$extension=null)

响应s first matched mime-type from extension, as mapped from gc_get_mime_types()

参数

$extension

(string) (Optional)

Default value: null

响应

(string|false)

源文件

文件: gc-includes/class-gc-image-editor.php

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

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

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

		return false;
	}