wp_ext2type

Definition:
function wp_ext2type( $ext ) {}

Retrieve the file type based on the extension name.

Parameters

  • string $ext: The extension to search.

Return values

returns:The file type, example: audio, video, document, spreadsheet, etc. Null if not found.

Defined filters

  • ext2type
    apply_filters( 'ext2type', array(

    'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' )

Source code

function wp_ext2type( $ext ) {

	$ext2type = apply_filters( 'ext2type', array(

		'audio'       => array( 'aac', 'ac3',  'aif',  'aiff', 'm3a',  'm4a',   'm4b', 'mka', 'mp1', 'mp2',  'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),

		'video'       => array( 'asf', 'avi',  'divx', 'dv',   'flv',  'm4v',   'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt',  'rm', 'vob', 'wmv' ),

		'document'    => array( 'doc', 'docx', 'docm', 'dotm', 'odt',  'pages', 'pdf', 'rtf', 'wp',  'wpd' ),

		'spreadsheet' => array( 'numbers',     'ods',  'xls',  'xlsx', 'xlsb',  'xlsm' ),

		'interactive' => array( 'key', 'ppt',  'pptx', 'pptm', 'odp',  'swf' ),

		'text'        => array( 'asc', 'csv',  'tsv',  'txt' ),

		'archive'     => array( 'bz2', 'cab',  'dmg',  'gz',   'rar',  'sea',   'sit', 'sqx', 'tar', 'tgz',  'zip', '7z' ),

		'code'        => array( 'css', 'htm',  'html', 'php',  'js' ),

	));

	foreach ( $ext2type as $type => $exts )

		if ( in_array( $ext, $exts ) )

			return $type;

}

3647

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: