wp_ext2type( string $ext ): string|void

In this article

Retrieves the file type based on the extension name.

Parameters

$extstringrequired
The extension to search.

Return

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

Source

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

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

Changelog

VersionDescription
2.5.0Introduced.

User Contributed Notes

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