From 1de9497eefe6c071c135f3e60ab6ec747af3f6d5 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Sat, 14 Sep 2013 14:33:19 +0000 Subject: [PATCH] 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 --- src/wp-includes/functions.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index d5b3ed1e3e..c4dc1e72db 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -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 ); -} \ No newline at end of file +}