Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_ext2type [ WordPress Function ]

wp_ext2type ( $ext )
Parameters:
  • (string) $ext The extension to search.
Uses:
Returns:
  • (string|null) The file type, example: audio, video, document, spreadsheet, etc. Null if not found.
Defined at:



Retrieve the file type based on the extension name.

Source


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

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics