Skip to content

Administration: Create site icon sizes for exact-size images in General Settings. - #14280

Open
rvpatel wants to merge 1 commit into
WordPress:trunkfrom
rvpatel:66309-site-icon-exact-size-crop
Open

rvpatel wants to merge 1 commit into
WordPress:trunkfrom
rvpatel:66309-site-icon-exact-size-crop

Conversation

@rvpatel

@rvpatel rvpatel commented Oct 14, 2026

Copy link
Copy Markdown

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-image request with the site-icon context, so they are never generated. Favicons and app icons then fall back to the regular thumbnail (150px) and medium (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-image request with the site-icon context, and reuses the existing cropped handler 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

  1. Go to Settings > General.
  2. Under Site Icon, choose an image that is exactly 512×512 and click "Set as Site Icon".
  3. The modal closes without the crop step and the previews update. Click "Save Changes".
  4. In Media > Library, a new cropped-… image is created for the site icon.
  5. Check the generated sizes, e.g. wp eval 'print_r( array_keys( wp_get_attachment_metadata( get_option( "site_icon" ) )["sizes"] ) );': it now includes site_icon-32, site_icon-64, site_icon-180, site_icon-192 and site_icon-270.
  6. Choosing an image of any other size still opens the cropper, as before.

Before this change, step 5 only lists thumbnail and medium, and get_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.

…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.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ravipatel.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant