public
Last active

WordPress snippet: add uploadable file types

  • Download Gist
uploadables.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/**
* Add uploadable mime types / file extensions
*/
function dc_add_uploadables($arr = array()) {
$new = array(
// Add file extension => mime type mapping here
'keynote|key' => 'application/vnd.apple.keynote',
'numbers' => 'application/vnd.apple.numbers',
'pages' => 'application/vnd.apple.pages'
);
 
$arr = array_merge($arr, $new);
return $arr;
}
 
if ( function_exists( 'wp_get_mime_types' ) ) {
// @since WordPress 3.5.0
add_filter('mime_types', 'dc_add_uploadables');
} else {
add_filter('upload_mimes', 'dc_add_uploadables');
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.