Add 'image' type/extensions to wp_ext2type() and make it case insensitive. props xparham. fixes #25176.

git-svn-id: https://develop.svn.wordpress.org/trunk@25437 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2013-09-14 14:33:19 +00:00
parent 87e014a245
commit 1de9497eef
1 changed files with 7 additions and 2 deletions

View File

@ -1813,7 +1813,9 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
* @return string|null The file type, example: audio, video, document, spreadsheet, etc. Null if not found.
*/
function wp_ext2type( $ext ) {
$ext = strtolower( $ext );
$ext2type = apply_filters( 'ext2type', array(
'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ),
'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
'video' => array( 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ),
'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'rtf', 'wp', 'wpd' ),
@ -1822,10 +1824,13 @@ function wp_ext2type( $ext ) {
'text' => array( 'asc', 'csv', 'tsv', 'txt' ),
'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ),
'code' => array( 'css', 'htm', 'html', 'php', 'js' ),
));
) );
foreach ( $ext2type as $type => $exts )
if ( in_array( $ext, $exts ) )
return $type;
return null;
}
/**
@ -4211,4 +4216,4 @@ function mbstring_binary_safe_encoding( $reset = false ) {
*/
function reset_mbstring_encoding() {
mbstring_binary_safe_encoding( true );
}
}