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`.

Merge of [34056] to the 4.3 branch.

Props tyxla.
See #33417.
Built from https://develop.svn.wordpress.org/branches/4.3@34057


git-svn-id: http://core.svn.wordpress.org/branches/4.3@34025 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-09-11 20:16:48 +00:00
parent 2a95fc38b2
commit b04ce4a437
2 changed files with 10 additions and 4 deletions

View File

@ -2163,14 +2163,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 );
},

File diff suppressed because one or more lines are too long