Embeds: Fix get_site_icon_url() dropping fallback when attachment URL…#11601
Embeds: Fix get_site_icon_url() dropping fallback when attachment URL…#11601Sukhendu2002 wants to merge 17 commits into
Conversation
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. |
|
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 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. |
|
Can we add tests for I see there are existing tests for |
There was a problem hiding this comment.
Pull request overview
Fixes a regression where get_site_icon_url() could drop a provided fallback URL when the attachment URL lookup fails, and updates embed site-title rendering to avoid emitting broken/empty icon attributes.
Changes:
- Preserve the caller-provided fallback URL in
get_site_icon_url()whenwp_get_attachment_image_url()returns false. - Refactor
the_embed_site_title()to conditionally render the site icon markup and omitsrcsetwhen appropriate. - Add PHPUnit coverage for the fallback behavior and embed site title icon output edge cases (attachment URL failure, empty URL, identical 1x/2x URLs, no site icon set).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/phpunit/tests/general/template.php | Adds tests for get_site_icon_url() fallback retention and the_embed_site_title() icon/srcset behaviors. |
| src/wp-includes/general-template.php | Ensures attachment URL failures don’t overwrite a provided fallback URL in get_site_icon_url(). |
| src/wp-includes/embed.php | Adjusts embed site title markup to avoid empty src/broken srcset and to omit the icon when URL is empty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Thanks for the iterations. Changes looks good to me.
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Previously, `get_site_icon_url()` overwrote a caller-supplied fallback URL with the return value of `wp_get_attachment_image_url()` even when that lookup returned `false`, so a defined fallback (such as the bundled WordPress logo) was silently discarded whenever the assigned site icon attachment could not be resolved. Only update the URL when a non-empty attachment URL is returned. Additionally, `the_embed_site_title()` now renders the site icon `<img>` only when a URL is available, and omits the `srcset` attribute when the 2x URL is missing or identical to the 1x URL. This avoids the malformed markup (an empty `src` and a bare ` 2x` `srcset`) that produced a broken image and spurious requests in oEmbed cards. Developed in #11601. Follow-up to r35571, r36693, r47832. Props sukhendu2002, sabernhardt, mukesh27, westonruter, pontocinza, mohamedahamed, abcd95, manhar, rollybueno. Fixes #65098. git-svn-id: https://develop.svn.wordpress.org/trunk@62502 602fd350-edb4-49c9-b593-d223f7449a82
Previously, `get_site_icon_url()` overwrote a caller-supplied fallback URL with the return value of `wp_get_attachment_image_url()` even when that lookup returned `false`, so a defined fallback (such as the bundled WordPress logo) was silently discarded whenever the assigned site icon attachment could not be resolved. Only update the URL when a non-empty attachment URL is returned. Additionally, `the_embed_site_title()` now renders the site icon `<img>` only when a URL is available, and omits the `srcset` attribute when the 2x URL is missing or identical to the 1x URL. This avoids the malformed markup (an empty `src` and a bare ` 2x` `srcset`) that produced a broken image and spurious requests in oEmbed cards. Developed in WordPress/wordpress-develop#11601. Follow-up to r35571, r36693, r47832. Props sukhendu2002, sabernhardt, mukesh27, westonruter, pontocinza, mohamedahamed, abcd95, manhar, rollybueno. Fixes #65098. Built from https://develop.svn.wordpress.org/trunk@62502 git-svn-id: http://core.svn.wordpress.org/trunk@61783 1a063a9b-81f0-0310-95a4-ce76da25c4cd


Trac ticket: https://core.trac.wordpress.org/ticket/65098
Use of AI Tools
AI assistance: No
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.