mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 08:11:52 +01:00
Add 'image' type/extensions to wp_ext2type() and make it case insensitive. props xparham. fixes #25176.
Built from https://develop.svn.wordpress.org/trunk@25437 git-svn-id: http://core.svn.wordpress.org/trunk@25359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bbd3312389
commit
32aff2db8a
@ -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.
|
* @return string|null The file type, example: audio, video, document, spreadsheet, etc. Null if not found.
|
||||||
*/
|
*/
|
||||||
function wp_ext2type( $ext ) {
|
function wp_ext2type( $ext ) {
|
||||||
|
$ext = strtolower( $ext );
|
||||||
$ext2type = apply_filters( 'ext2type', array(
|
$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' ),
|
'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' ),
|
'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' ),
|
'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' ),
|
'text' => array( 'asc', 'csv', 'tsv', 'txt' ),
|
||||||
'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ),
|
'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ),
|
||||||
'code' => array( 'css', 'htm', 'html', 'php', 'js' ),
|
'code' => array( 'css', 'htm', 'html', 'php', 'js' ),
|
||||||
));
|
) );
|
||||||
|
|
||||||
foreach ( $ext2type as $type => $exts )
|
foreach ( $ext2type as $type => $exts )
|
||||||
if ( in_array( $ext, $exts ) )
|
if ( in_array( $ext, $exts ) )
|
||||||
return $type;
|
return $type;
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user