From e971dd25bca95be47d56c38e466c6e97ffb829bd Mon Sep 17 00:00:00 2001 From: rvpatel Date: Wed, 14 Oct 2026 21:03:47 +0530 Subject: [PATCH] Administration: Create site icon sizes for exact-size images in General Settings. When an image that already has the required site icon dimensions (512x512) is selected in Settings > General, the crop step is skipped and the original image is saved as the site icon, so the site icon sizes (32, 64, 180, 192 and 270) are never generated. Send the image through the crop-image request with the `site-icon` context, as the Customizer already does, so the site icon and its sizes are created. See #66309. --- src/js/_enqueues/admin/site-icon.js | 36 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/js/_enqueues/admin/site-icon.js b/src/js/_enqueues/admin/site-icon.js index 59a098dc08aac..6e8c03f64ed8e 100644 --- a/src/js/_enqueues/admin/site-icon.js +++ b/src/js/_enqueues/admin/site-icon.js @@ -117,17 +117,37 @@ // When an image is selected, run a callback. frame.on( 'select', function () { // Grab the selected attachment. - var attachment = frame.state().get( 'selection' ).first(); + var attachment = frame.state().get( 'selection' ).first(), + size = $el.data( 'size' ); if ( - attachment.attributes.height === $el.data( 'size' ) && - $el.data( 'size' ) === attachment.attributes.width + attachment.attributes.height === size && + size === attachment.attributes.width ) { - switchToUpdate( attachment.attributes ); - frame.close(); - - // Set the value of the hidden input to the attachment id. - $hiddenDataField.val( attachment.id ); + /* + * The image doesn't need cropping, but it still goes through the crop + * request so that the site icon and its additional sizes are created. + */ + wp.ajax + .post( 'crop-image', { + nonce: attachment.get( 'nonces' ).edit, + id: attachment.id, + context: 'site-icon', + cropDetails: { + x1: 0, + y1: 0, + width: size, + height: size, + dst_width: size, + dst_height: size, + }, + } ) + .done( function ( croppedImage ) { + frame.trigger( 'cropped', croppedImage ); + } ) + .fail( function () { + frame.trigger( 'content:error:crop' ); + } ); } else { frame.setState( 'cropper' ); }