From 156c5fef0f60106906fa20510bd829fd165cd27f Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 4 Dec 2012 04:04:45 +0000 Subject: [PATCH] Media: When an image does not have all image sizes available, make sure we insert the requested size into the editor. props koopersmith. fixes #22693. git-svn-id: http://core.svn.wordpress.org/trunk@23008 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-views.js | 12 ++++++++++-- wp-includes/media.php | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 704005af4e..372096da1e 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -3745,7 +3745,7 @@ update: function( key ) { var value = this.model.get( key ), $setting = this.$('[data-setting="' + key + '"]'), - $buttons; + $buttons, $value; // Bail if we didn't find a matching setting. if ( ! $setting.length ) @@ -3756,7 +3756,15 @@ // Handle dropdowns. if ( $setting.is('select') ) { - $setting.find('[value="' + value + '"]').attr( 'selected', true ); + $value = $setting.find('[value="' + value + '"]'); + + if ( $value.length ) { + $value.attr( 'selected', true ); + } else { + // If we can't find the desired value, record what *is* selected. + this.model.set( $setting.data('setting'), $setting.find('[selected]').val() ); + } + // Handle button groups. } else if ( $setting.hasClass('button-group') ) { diff --git a/wp-includes/media.php b/wp-includes/media.php index 7bd8ad2349..f4a9807786 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1825,10 +1825,10 @@ function wp_print_media_templates() { <# var size = data.sizes['']; if ( size ) { #> - - <# } #>> + <# } #>