check_upload_mimes

Check an array of MIME types against a whitelist.

Description

(array) check_upload_mimes( (array) $mimes ); 

WordPress ships with a set of allowed upload filetypes, which is defined in wp-includes/functions.php in get_allowed_mime_types(). This function is used to filter that list against the filetype whitelist provided by Multisite Super Admins at wp-admin/network/settings.php.

Returns (array)

Parameters (1)

0. $mimes (array)
The mimes.

Usage

  1. if ( !function_exists( 'check_upload_mimes' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4. // The mimes. 
  5. $mimes = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = check_upload_mimes($mimes); 
  9.  

Defined (1)

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

/wp-includes/ms-functions.php  
  1. function check_upload_mimes( $mimes ) { 
  2. $site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) ); 
  3. $site_mimes = array(); 
  4. foreach ( $site_exts as $ext ) { 
  5. foreach ( $mimes as $ext_pattern => $mime ) { 
  6. if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) 
  7. $site_mimes[$ext_pattern] = $mime; 
  8. return $site_mimes;