W3cubDocs

/WordPress

WP_Image_Editor::get_mime_type( string $extension = null )

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

Description

Parameters

$extension

(string) (Optional)

Default value: null

Return

(string|false)

Source

File: wp-includes/class-wp-image-editor.php

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;
	}

Changelog

Version Description
3.5.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_image_editor/get_mime_type