Repository navigation
Conversation
…al 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.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Thanks for the PR @rvpatel - the code looks fine on the face of it, but I'm not sure this is the best approach. It creates an additional request and could require different capabilities than the current flow, possibly silently failing. I chatted with Claude about this to come up with some alternate approaches. I chose a couple possibilities to consider:
Essentially silently fix the issue silently by creating the missing sizes when the option gets saved. The advantage here is it ensures site icons always work, no matter where the icon comes from , including REST and WP-CLI. It feels a little kludgy to me though.
This is what @jorbin and @joedolson asked for on https://core.trac.wordpress.org/ticket/64020. It makes the two screens behave the same. "Skip Cropping" in the Customizer still sends the full image through crop-image, so it keeps the duplicate copy and the re-encoding.So its the current PR with an extra button. It would fix #64020 and #66309 together. What do you think? |
adamsilverstein
left a comment
There was a problem hiding this comment.
Code is good, consider alternate approaches
In Settings > General, show the "Skip cropping" button for square images, as the Customizer does. Skipping still sends the whole image through the `crop-image` request with the `site-icon` context, so the site icon sizes are created. See #64020, #66309.
|
Thanks @adamsilverstein, and sorry for the slow reply. I went with option 4 and pushed it in 418052e: General Settings now shows the "Skip cropping" button for square images, as the Customizer does. How it works: On your concerns about the extra request:
I tested it in a browser (Chromium via Playwright) on trunk's General Settings:
Each icon created with the PR has This should cover #64020 as well as #66309. I'd still like your view on option 1 as a follow-up, since icons set through REST or WP-CLI also miss these sizes. |
In Settings > General, when the selected Site Icon image is already exactly 512×512, the crop step is skipped and the original image is saved as the site icon. The site icon sizes (32, 64, 180, 192 and 270) are only created by the
crop-imagerequest with thesite-iconcontext, so they are never generated. Favicons and app icons then fall back to the regularthumbnail(150px) andmedium(300px) sizes. Square images of other sizes also always have to go through the cropper, while the Customizer offers "Skip cropping" (#64020).The Customizer's Site Icon control handles both cases. Exact-size images still go through a full-size "crop" request (
wp.customize.SiteIconControl.onSelect()), and square images get a "Skip cropping" button that also sends the whole image throughcrop-image. Both were lost when the control was brought to the General Settings screen in 6.5.This PR:
crop-imagerequest with thesite-iconcontext, and reuses the existingcroppedhandler to update the field and previews. A failed request shows the media modal's crop error.hasRequiredAspectRatioandsuggestedCropSizeincalculateImageSelectOptions(), as the Customizer does, so the cropper shows "Skip cropping" for square images. Skipping crops the whole image to 512×512, so the site icon sizes are created.Trac tickets: https://core.trac.wordpress.org/ticket/66309, https://core.trac.wordpress.org/ticket/64020
Testing Instructions
cropped-…image is created for the site icon.wp eval 'print_r( array_keys( wp_get_attachment_metadata( get_option( "site_icon" ) )["sizes"] ) );': it includessite_icon-32,site_icon-64,site_icon-180,site_icon-192andsite_icon-270.Before this change, step 2 saves the original image, step 6 only lists
thumbnailandmedium, andget_site_icon_url( 32 )returns the 150×150 image. Step 3 shows only "Crop image".Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Investigating the cause, writing the fix, testing it in a browser and writing this description. I reviewed the code and the results.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.