bp_attachments_get_allowed_mimes

Get allowed attachment mime types.

Description

(array) bp_attachments_get_allowed_mimes( (string) $type = '', (array) $allowed_types = array() ); 

Returns (array)

List of allowed mime types.

Parameters (2)

0. $type — Optional. (string) => ''
The extension types to get (Optional).
1. $allowed_types — Optional. (array) => array()
List of allowed extensions.

Usage

  1. if ( !function_exists( 'bp_attachments_get_allowed_mimes' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-attachments.php'; 
  3.  
  4. // The extension types to get (Optional). 
  5. $type = ''; 
  6.  
  7. // List of allowed extensions. 
  8. $allowed_types = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_attachments_get_allowed_mimes($type, $allowed_types); 
  12.  

Defined (1)

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

/bp-core/bp-core-attachments.php  
  1. function bp_attachments_get_allowed_mimes( $type = '', $allowed_types = array() ) { 
  2. if ( empty( $allowed_types ) ) { 
  3. $allowed_types = bp_attachments_get_allowed_types( $type ); 
  4.  
  5. $validate_mimes = wp_match_mime_types( join( ', ', $allowed_types ), wp_get_mime_types() ); 
  6. $allowed_mimes = array_map( 'implode', $validate_mimes ); 
  7.  
  8. /** 
  9. * Include jpg type if jpeg is set 
  10. */ 
  11. if ( isset( $allowed_mimes['jpeg'] ) && ! isset( $allowed_mimes['jpg'] ) ) { 
  12. $allowed_mimes['jpg'] = $allowed_mimes['jpeg']; 
  13.  
  14. return $allowed_mimes;