Skip to content

Embeds: Fix get_site_icon_url() dropping fallback when attachment URL…#11601

Closed
Sukhendu2002 wants to merge 17 commits into
WordPress:trunkfrom
Sukhendu2002:fix/65098-get-site-icon-url-fallback
Closed

Embeds: Fix get_site_icon_url() dropping fallback when attachment URL…#11601
Sukhendu2002 wants to merge 17 commits into
WordPress:trunkfrom
Sukhendu2002:fix/65098-get-site-icon-url-fallback

Conversation

@Sukhendu2002

@Sukhendu2002 Sukhendu2002 commented Apr 20, 2026

Copy link
Copy Markdown

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.

@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.

Comment thread src/wp-includes/embed.php Outdated
@Sukhendu2002 Sukhendu2002 marked this pull request as ready for review April 20, 2026 07:58
@github-actions

github-actions Bot commented Apr 20, 2026

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 sukhendu2002, westonruter, mukesh27, sabernhardt.

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

Comment thread src/wp-includes/embed.php Outdated
@westonruter

Copy link
Copy Markdown
Member

Can we add tests for get_site_icon_url() and the_embed_site_title() to cover the new code paths?

I see there are existing tests for get_site_icon_url() in tests/phpunit/tests/general/template.php but I don't see existing coverage for the_embed_site_title().

Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
@westonruter westonruter requested review from Copilot and removed request for sabernhardt April 24, 2026 00:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() when wp_get_attachment_image_url() returns false.
  • Refactor the_embed_site_title() to conditionally render the site icon markup and omit srcset when 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.

Comment thread src/wp-includes/embed.php Outdated
Comment thread tests/phpunit/tests/general/template.php Outdated
Comment thread tests/phpunit/tests/general/template.php

@mukeshpanchal27 mukeshpanchal27 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the iterations. Changes looks good to me.

@westonruter

Copy link
Copy Markdown
Member

Double-checking this.

With the following plugin code in place:

add_filter( 'wp_get_attachment_image_src', '__return_false' );

When accessing a post that has another post embedded:

Before:

image

After:

image

So it's working well for me.

pento pushed a commit that referenced this pull request Jun 15, 2026
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
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62502
GitHub commit: 68cbdc9

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Jun 15, 2026
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jun 15, 2026
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
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.

5 participants