WP_Image_Editor::get_extension() WordPress Method

The WP_Image_Editor::get_extension() method is used to get the file extension for an image. This is useful for getting the correct file extension when you are working with images.

WP_Image_Editor::get_extension( string $mime_type = null ) #

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


Parameters

$mime_type

(string)(Optional)

Default value: null


Top ↑

Return

(string|false)


Top ↑

Source

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

	protected static function get_extension( $mime_type = null ) {
		if ( empty( $mime_type ) ) {
			return false;
		}

		return wp_get_default_extension_for_mime_type( $mime_type );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.