wp_ext2type

Retrieve the file type based on the extension name.

Description

(string|void) wp_ext2type( (string) $ext ); 

Returns (string|void)

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

Parameters (1)

0. $ext (string)
The extension to search.

Usage

  1. if ( !function_exists( 'wp_ext2type' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // The extension to search. 
  5. $ext = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_ext2type($ext); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_ext2type( $ext ) { 
  2. $ext = strtolower( $ext ); 
  3.  
  4. $ext2type = wp_get_ext_types(); 
  5. foreach ( $ext2type as $type => $exts ) 
  6. if ( in_array( $ext, $exts ) ) 
  7. return $type;