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, 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.The Customizer's Site Icon control handles the same case by still sending a full-size "crop" request (
wp.customize.SiteIconControl.onSelect()). This was lost when the control was brought to the General Settings screen in 6.5.This PR sends exact-size images through the same
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.Trac ticket: https://core.trac.wordpress.org/ticket/66309
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 now includessite_icon-32,site_icon-64,site_icon-180,site_icon-192andsite_icon-270.Before this change, step 5 only lists
thumbnailandmedium, andget_site_icon_url( 32 )returns the 150×150 image.Props ravipatel.
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 and this description. I reproduced the issue, tested the fix locally, and take responsibility for it.
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.