wp_ext2type( string $ext )

Retrieve the file type based on the extension name.


Description Description


Parameters Parameters

$ext

(string) (Required) The extension to search.


Top ↑

Return Return

(string|void) The file type, example: audio, video, document, spreadsheet, etc.


Top ↑

Source Source

File: wp-includes/functions.php

function wp_ext2type( $ext ) {
	$ext = strtolower( $ext );

	$ext2type = wp_get_ext_types();
	foreach ( $ext2type as $type => $exts ) {
		if ( in_array( $ext, $exts ) ) {
			return $type;
		}
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.