From 8e403519dbc2cc0c3c2add9b0a0bf79bd92f1e5b Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 18 Mar 2014 03:24:17 +0000 Subject: [PATCH] TinyMCE gallery preview: fix errors when an image doesn't have/is smaller than thumbnail size, props gcorne, see #26959 git-svn-id: https://develop.svn.wordpress.org/trunk@27580 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/mce-view.js | 15 +++++++++++++-- src/wp-includes/media-template.php | 10 +--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index 0881680b77..7d5f051574 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -268,14 +268,25 @@ window.wp = window.wp || {}; getHtml: function() { var attrs = this.shortcode.attrs.named, - options; + options, + attachments; if ( ! this.attachments.length ) { return; } + attachments = this.attachments.toJSON(); + + _.each( attachments, function( attachment ) { + if ( attachment.sizes.thumbnail ) { + attachment.thumbnail = attachment.sizes.thumbnail; + } else { + attachment.thumbnail = attachment.sizes.full; + } + } ); + options = { - attachments: this.attachments.toJSON(), + attachments: attachments, columns: attrs.columns ? parseInt( attrs.columns, 10 ) : 3 }; diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 345935a91e..946e506a88 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -897,12 +897,6 @@ function wp_print_media_templates() { - -