From c7eca8e2d5015cd4f8d1fa8464ae83d9e3901d04 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Fri, 7 Sep 2012 21:27:07 +0000 Subject: [PATCH] Use icons for non-image attachments in the new media modal. see #21836, #21390, #21808. git-svn-id: https://develop.svn.wordpress.org/trunk@21784 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-views.js | 14 ++++++++++---- wp-includes/media.php | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index a7913cf0cb..032b5d85f2 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -527,12 +527,14 @@ render: function() { var attachment = this.model.toJSON(), options = { + thumbnail: 'image' === attachment.type ? attachment.url : attachment.icon, + uploading: attachment.uploading, orientation: attachment.orientation || 'landscape', - thumbnail: attachment.url || '', - uploading: attachment.uploading + type: attachment.type, + subtype: attachment.subtype }; - // Use the medium size if possible. If the medium size + // Use the medium image size if possible. If the medium size // doesn't exist, then the attachment is too small. // In that case, use the attachment itself. if ( attachment.sizes && attachment.sizes.medium ) { @@ -614,7 +616,11 @@ options.count = this.collection.length; first = this.collection.first(); sizes = first.get('sizes'); - options.thumbnail = ( sizes && sizes.thumbnail ) ? sizes.thumbnail.url : first.get('url'); + + if ( 'image' === first.get('type') ) + options.thumbnail = ( sizes && sizes.thumbnail ) ? sizes.thumbnail.url : first.get('url'); + else + options.thumbnail = first.get('icon'); this.$el.html( this.template( options ) ); return this; diff --git a/wp-includes/media.php b/wp-includes/media.php index 0d9b3708c6..9f6df8db48 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1576,6 +1576,7 @@ function wp_prepare_attachment_for_js( $attachment ) { 'mime' => $attachment->post_mime_type, 'type' => $type, 'subtype' => $subtype, + 'icon' => wp_mime_type_icon( $attachment->post_mime_type ), ); if ( $meta && 'image' === $type ) { @@ -1646,7 +1647,7 @@ function wp_print_media_templates( $attachment ) {