added check to make sure thumbnail url exists otherwise fallback to main url

This commit is contained in:
splashingpixels 2014-05-23 07:29:08 -07:00
parent 029bed8631
commit 7e787530e3
2 changed files with 4 additions and 3 deletions

View File

@ -356,11 +356,12 @@ jQuery( function ( $ ) {
// When an image is selected, run a callback.
variable_image_frame.on( 'select', function () {
var attachment = variable_image_frame.state().get( 'selection' ).first().toJSON();
var attachment = variable_image_frame.state().get( 'selection' ).first().toJSON(),
url = attachment.sizes.thumbnail ? attachment.sizes.thumbnail.url : attachment.url;
setting_variation_image.find( '.upload_image_id' ).val( attachment.id );
setting_variation_image.find( '.upload_image_button' ).addClass( 'remove' );
setting_variation_image.find( 'img' ).eq( 0 ).attr( 'src', attachment.sizes.thumbnail.url );
setting_variation_image.find( 'img' ).eq( 0 ).attr( 'src', url );
wp.media.model.settings.post.id = wp_media_post_id;
});

File diff suppressed because one or more lines are too long