From 9805723e3dc86d73c8bd8e77b6975894d7172702 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Fri, 11 Sep 2015 20:12:50 +0000 Subject: [PATCH] Site Icon: For preview fall back to `full` size URL when `thumbnail` size doesn't exist. Prevents a JavaScript error for rare cases when cropping is skipped and the image is smaller than `thumbnail`. Props tyxla. Fixes #33417. git-svn-id: https://develop.svn.wordpress.org/trunk@34056 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 3e4005d45c..ce75e4b5f6 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -2182,14 +2182,20 @@ * @param {object} attachment */ setImageFromAttachment: function( attachment ) { - var icon = typeof attachment.sizes['site_icon-32'] !== 'undefined' ? attachment.sizes['site_icon-32'] : attachment.sizes.thumbnail; + var sizes = [ 'site_icon-32', 'thumbnail', 'full' ], + icon; + + _.each( sizes, function( size ) { + if ( ! icon && ! _.isUndefined ( attachment.sizes[ size ] ) ) { + icon = attachment.sizes[ size ]; + } + } ); this.params.attachment = attachment; // Set the Customizer setting; the callback takes care of rendering. this.setting( attachment.id ); - // Update the icon in-browser. $( 'link[sizes="32x32"]' ).attr( 'href', icon.url ); },