fix: Facebook embed in Gutenberg block fails for reel URLs (fbs-82016)#269
Open
AmitPaul-akp wants to merge 1 commit into
Open
fix: Facebook embed in Gutenberg block fails for reel URLs (fbs-82016)#269AmitPaul-akp wants to merge 1 commit into
AmitPaul-akp wants to merge 1 commit into
Conversation
WP core's oEmbed discovery resolves facebook.com/reel/{id} URLs to
the Graph API endpoint, which then fails with "Provide valid app ID"
when no FB app token is configured. The OAuth error gets merged into
the response object alongside the valid iframe HTML produced by
Embera's local Facebook provider fallback.
The Gutenberg block JS rejects any response with an `error` field
even when `embed` is populated, so the editor shows "Sorry, we could
not embed that content." Elementor's widget consumes the server-
rendered `embed` directly and has no such guard, which is why the
same URL renders there.
Strip `error` from the merged response when the fallback produced
real embed HTML (iframe / embed / script / blockquote / video /
object). No behaviour change for any provider where `error` wasn't
present, and the fallback iframe itself is unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Affected version: 4.5.4
Severity: Medium
Summary
The EmbedPress Gutenberg block shows "Sorry, we could not embed that content." for Facebook reel URLs (e.g.
https://www.facebook.com/reel/2408092022903533), even though the same URL renders correctly via the Elementor EmbedPress widget. The block consumes a REST response that carries both a validembedfield and a staleerrorfield from a failed FB Graph API call; the block's JS guard rejects anything witherrorset, dropping a perfectly good iframe.Reproduction (before fix)
Environment used to reproduce:
Steps:
https://www.facebook.com/reel/2408092022903533and click Embed.cannotEmbed: true).facebook.com/{user}/videos/{id}andfacebook.com/{user}/posts/{id}URLs in the same block.Why it's reel-specific:
WP_oEmbed::get_provider()performs HTTP discovery onfacebook.com/reel/...and resolves it tograph.facebook.com/v25.0/oembed_video?.... Calling that endpoint without an FB app token returns(#200) Provide valid app ID.WP_oEmbed::fetch()attaches the error payload to$urlData. Embera's local Facebook provider then runs as a fallback and fills in a valid static iframe in$parsedContent, but theerrorfrom$urlDatais preserved througharray_mergeinto the final response. Regular FB video/post URLs aren't affected becauseget_provider()returnsfalsefor them and the Graph API call never happens.The block JS guard (
assets/js/blocks.build.js) reads:So any non-empty
errorfield nukes an otherwise-validembed.Fix
File:
EmbedPress/Shortcode.php— insideparseContent(), just before the finalarray_merge(~ line 581)Why it's safe:
errorwhen the assembled embed HTML actually contains an embeddable element (<iframe>/<embed>/<script>/<blockquote>/<video>/<object>). If the fallback produced nothing,errorstill propagates and the block correctly shows the "cannot embed" state.errorin the first place.Test plan
https://www.facebook.com/reel/2408092022903533→ expect inline iframe preview (no "could not embed" error)https://www.facebook.com/{user}/videos/{id}→ still renders correctly (regression check)https://www.facebook.com/{user}/posts/{id}→ still renders correctly (regression check)https://example.com/nope) in Gutenberg block → still shows "Sorry, we could not embed that content." (negative regression check —errormust still propagate when no embed HTML is produced)Build artifacts
Hotfix zip built from this branch (
fb-embed-gutenberg-fix), version kept at 4.5.4 (no version bump per internal convention) — attached to the Fluent Boards card linked below.Related