diff --git a/src/wp-includes/post-functions.php b/src/wp-includes/post-functions.php index c4640d5fe7..04f888a055 100644 --- a/src/wp-includes/post-functions.php +++ b/src/wp-includes/post-functions.php @@ -5081,11 +5081,16 @@ function wp_mime_type_icon( $mime = 0 ) { $matches['default'] = array('default'); foreach ( $matches as $match => $wilds ) { - if ( isset($types[$wilds[0]])) { - $icon = $types[$wilds[0]]; - if ( !is_numeric($mime) ) - wp_cache_add("mime_type_icon_$mime", $icon); - break; + foreach ( $wilds as $wild ) { + if ( ! isset( $types[ $wild ] ) ) { + continue; + } + + $icon = $types[ $wild ]; + if ( ! is_numeric( $mime ) ) { + wp_cache_add( "mime_type_icon_$mime", $icon ); + } + break 2; } } } diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php index 7633fd1f89..7459c6ae4c 100644 --- a/tests/phpunit/tests/post/attachments.php +++ b/tests/phpunit/tests/post/attachments.php @@ -512,9 +512,9 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $upload = wp_upload_bits( basename( $filename ), null, $contents ); - $this->assertNotEmpty( $upload['error'] ); - remove_filter( 'upload_mimes', array( $this, 'blacklist_jpg_mime_type' ) ); + + $this->assertNotEmpty( $upload['error'] ); } public function whitelist_psd_mime_type( $mimes ) { @@ -526,4 +526,22 @@ class Tests_Post_Attachments extends WP_UnitTestCase { unset( $mimes['jpg|jpeg|jpe'] ); return $mimes; } + + /** + * @ticket 33012 + */ + public function test_wp_mime_type_icon() { + $icon = wp_mime_type_icon(); + + $this->assertContains( 'images/media/default.png', $icon ); + } + + /** + * @ticket 33012 + */ + public function test_wp_mime_type_icon_video() { + $icon = wp_mime_type_icon( 'video/mp4' ); + + $this->assertContains( 'images/media/video.png', $icon ); + } }