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
YouTube urls with /embed/
in the url fail to embed
#4127
Comments
I can confirm this unexpected behaviour, all that is rendered is an empty div, tested on the latest master branch (prep for 2.0).
Even the help text suggests a URL in this format I cannot really get to the bottom of the cause, the closest I got was that this type of URL does not seem to be matching in the wagtail/wagtail/embeds/oembed_providers.py Lines 16 to 29 in 26d9fb4
When the URL cannot be matched it throws I could be way off here but this is as far as I got investigating this one, but definitely appears to be an issue. |
@lb- Where are you seeing that? As far as I can see, all references to youtube.com in the codebase use youtube.com/watch/ URLs (with the exception of test code that's checking the final embed output). I don't think this is a bug as such, but I've seen people caught out by it before - it's not necessarily obvious that the URL we want is the one for the actual page on Youtube, and that as an editor you don't have to go through Youtube's own embedding mechanism. (In some cases people have tried pasting in the full embed HTML snippet, not just the URL...) So, I'm in favour of making the URL matching as permissive as possible. |
@gasman my apologies, this is actually something specific to the bakerydemo (code below), nonetheless I think we should try to handle this URL format as it seems a reasonable assumption by users/developers. I am right in thinking that we will just need to add an appropriate additional youtube regex?
|
Yep, try adding
to the list in oembed_providers.py. Can't say for sure that it will work - we pass the matched URL on to Youtube's oembed endpoint to generate the embed snippet, so it's up to the handler at Youtube's end whether or not they recognise /embed/... as a valid URL for that purpose. (If not, I guess we'd need to implement some extra logic to rewrite it into a URL they do recognise.) |
I have the URL being accepted locally but the embed is still not working. It appears that the Works
Does not work
Potential solution This might be a bit heavy handed but we could add the ability to set eg.
If the template is present, when parsing through the urls we would also check for matches against the template, but instead of using the original url we would expand - This would open a way to solve things like people pasting in the entire embed iframe code from YouTube. It adds a fair bit of complexity though but is quite backwards compatible. Otherwise we should close this ticket, maybe updating some doc/file explaining why that type of URL is not supported. |
I have a working version (needs tests/docs before I put in a PR) of the templates idea. See the revised oembed code here: A working template that here: Would love some feedback if it is worth adding this feature, happy to add tests / document this correctly. |
Can Anyone help me figure out why this particular video gives "Cannot find an embed for this URL" error when trying to embed it while other youtube videos embed just fine? |
@maxwaiyaki The uploader of the video has disabled embedding. From the youtube page, click "Share" then "Embed" and you'll see "Embedding disabled by request". |
@gasman Thank you. |
You can check this Magazine Out. Build with Wagtail - https://mag.mookh.com/ |
I have stumbled upon something similar recently where a URL that has a video id and a playlist like: https://www.youtube.com/watch?v=tdB1I_gSCeY&list=PLEyaio0l1qoEIUFM9bnRKoN6VKEUOdxAn … renders as a player showing just the playlist: https://www.youtube.com/embed/videoseries?list=PLEyaio0l1qoEIUFM9bnRKoN6VKEUOdxAn. As a user of the CMS I was expecting to be embedding the video I can see on YouTube from that URL rather than the first one in the playlist. This behavior comes from YouTube’s oembed response for that URL, https://www.youtube.com/oembed?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtdB1I_gSCeY%26list%3DPLEyaio0l1qoEIUFM9bnRKoN6VKEUOdxAn&format=json. Like @gasman says (#4127 (comment)) it makes me wonder whether it might be valuable to have extra logic for this scenario – it’s very confusing that the resulting embed is different from the YouTube UI. Note: the workaround in this scenario is of course to drop the playlist parameter from the query string, so https://www.youtube.com/watch?v=tdB1I_gSCeY. Edit: also related, https://wagtail.io/blog/fixing-youtubes-oembed-implementation-custom-finder-class/. |
Hello y'all I was looking for answer for days but I found it here: for some reason it did not show up on google 🤔 Short of it is:
.responsive-object {
position: relative;
}
.responsive-object iframe,
.responsive-object object,
.responsive-object embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
} and BOOM responsive embeddeds |
Issue Summary
Using an Embed block in a streamfield, we are able to embed videos from youtube.com like this
https://youtu.be/2MW6CrxScLk
or like thishttps://www.youtube.com/watch?v=2MW6CrxScLk
but not like thishttps://youtube.com/embed/2MW6CrxScLk
Steps to Reproduce
Grab a youtube url by clicking on a link that says "Embed".
Technical details
The text was updated successfully, but these errors were encountered: