-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embed proxy API does not return HTML in all cases, so some providers will not embed #5530
Comments
First PR to start addressing this is at #5333 which removes the need to get the |
Added some REST API task labels, because of the needed endpoint. CC: @aduth |
Second part of the fix is up at #5639 |
The Lines 272 to 273 in a3776ed
Introduced in #4226 (cc @imath) Worryingly, this logic is such that we're fetching from the oEmbed API twice for every embed, because the cache is not shared between the original fetch by the API and the call to And in some brief testing, Kickstarter does have rate limiting in effect, so the empty response may very well be the result of a failed second request.
|
If we're relying on some filtering to take place, the only thing different about what's happening in /**
* Filters the HTML returned by the oEmbed provider.
*
* @since 2.9.0
*
* @param string $data The returned oEmbed HTML.
* @param string $url URL of the content to be embedded.
* @param array $args Optional arguments, usually passed from a shortcode.
*/
return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args ); We could recreate this in our filter treating |
Ah, that would explain why sometimes we only get metadata and no html... Ok, well that filtering is only there if we're calling the embed proxy, and as this is a nee endpoint, it shouldn't be getting called. |
That would work for embeds that go through oembed, and I'm still keen on having the new endpoint because there are plugins that handle things like youtube and bypass oembed completely, which is why we're constructing the |
Can you elaborate on the purpose of a new endpoint? It's not entirely clear to me. Ideally we don't proliferate endpoints just to solve varying use-cases or backwards-compatibility considerations, as it sounds like a future-compatibility nightmare. |
Sure! The classic editor does embedded content previews by POSTing a request to We need something that does that for Gutenberg, and isn't tied to the admin area. We need that because |
This still sounds more like a bug with the existing proxy endpoint. |
I don't think it is. You can register new provider handlers with |
But, i realised I wasn't clear about why bypassing oEmbed with a custom callback is a problem 😄 The problems are that we can't rely on the |
Dropping by to note I tested this today and am confirming I was unable to add a Kickstarter link to an embed block—this error was returned when I tried testing:
Sample link used: https://www.kickstarter.com/projects/crowdcookware/the-blackbeard-the-essential-nonstick-nonscratch-f
|
@pento @mkaz could you take a look at this with me please? Kickstarts embeds intermittently fail - I think it's some kind of rate limiting going on because there's some code in |
Kickstarter does rate limiting, but it's pretty difficult to hit: I need to do 60 simultaneous I can reproduce the behaviour, it seems like I think we could actually return early from $wp_oembed = _wp_oembed_get_object();
if ( false !== $wp_oembed->get_provider( $_GET['url'], array( 'discover' => false ) ) ) {
return $response;
} If it's a trusted embed provider, we don't need to do the second pass of sanity checking. |
Closing as appears addressed in core and #10985. |
Issue Overview
Gutenberg uses the embed proxy API to get rendered HTML for URLs. This works for most cases, but the Kickstarter provider does not return any HTML, even though it returns a type of
rich
.The classic editor POSTs to
/wp-admin/admin-ajax.php
requesting that the URL is rendered using an[embed]
shortcode. This always returns HTML.We do not want to call
/wp-admin/admin-ajax.php
because that is tied into the wp-admin area only, so we need to have an API which does the same as the call that the classic editor makes, but exposed through the REST API.Steps to Reproduce (for bugs)
Note that sometimes on your second attempt to embed a specific KS url, it will return HTML, this is down to some inconsistent behaviour inside oembed. The
/wp-admin/admin-ajax.php
call will process the embed using the[embed]
shortcode, and this always gives the desired result. The code that the admin ajax actions uses can be pretty much copied into a REST API endpoint to give us what we need, and have the same embed previewing as in the classic editor.Todos
The text was updated successfully, but these errors were encountered: