sanitize_mime_type

Sanitize a mime type.

Description

(string) sanitize_mime_type( (string) $mime_type ); 

Returns (string)

Sanitized mime type

Parameters (1)

0. $mime_type (string)
The mime type.

Usage

  1. if ( !function_exists( 'sanitize_mime_type' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // The mime type. 
  5. $mime_type = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = sanitize_mime_type($mime_type); 
  9.  

Defined (1)

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

/wp-includes/formatting.php  
  1. function sanitize_mime_type( $mime_type ) { 
  2. $sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type ); 
  3. /** 
  4. * Filters a mime type following sanitization. 
  5. * @since 3.1.3 
  6. * @param string $sani_mime_type The sanitized mime type. 
  7. * @param string $mime_type The mime type prior to sanitization. 
  8. */ 
  9. return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );