Regular youtube video embedding works.
I don’t encounter this issue on try.discourse or meta.
I suppose it comes from a site setting not properly configured.
Could you just tell me what URL should I add in allowed iframes in order to have the video shown as you did? It would perfectly do the job for now, even if it’s tall indeed.
As for the video height, it’s possible to make it less tall by setting a max-height with CSS on the iframe. The issue is that the iframe has no attribute of any kind that specify that it’s a short (vertical) vidéo.
But then, what should I do in order to make the video appear?
If I write in my post https://www.youtube.com/shorts/SWeTMdyv50Q, it won’t work.
If I write <iframe>https://www.youtube.com/shorts/SWeTMdyv50Q</iframe>, it won’t work.
If I write https://www.youtube.com/embed/SWeTMdyv50Q, it will work, but will display the short video with standard youtube video width/height ratio (which is OK for me, though I’d prefer having another ratio and not having to manually write “embed” in the URL):
Also, replacing /shorts/ by watch?v=, the default URL of a Youtube video, works.
So, in youtube, on https://www.youtube.com/shorts/SWeTMdyv50Q, doing right click → Copy video URL will work since it returns https://youtu.be/SWeTMdyv50Q which is correctly displayed on Discourse (with the regular wide ratio though).
I’ve done it though I might have messed up a bit my pull request because for some reason, I’m still not used to GitHub… I really need to read the manual (and, a friend tells me, to create branches from my Discourse fork…).
Just for information, I just edited the file lib\onebox\engine\youtube_onebox.rb to add
# https://www.youtube.com/shorts/wi2jAtpBl0Y
if uri.path["/shorts/"]
id ||= uri.path[/\/shorts\/([\w\-]+)/, 1]
end
I’m just wondering if it would easier job to just change that url? Because youtube.com/shorts/something is totally same than youtube.com/embed/something, and with /embed/ oneboxing/embedding works just fine here.
I’m still not following you. Who would change the URL? The poster? But the poster doesn’t want to manually re-write part of an URL (they won’t even know why the video doesn’t embed), they just want to copy-paste, and boom, it works.
Edit: or do you mean that Discourse’s Oneboxing code would replace /shorts/ by /embed/?
it "can parse youtube shorts results" do
preview = expect(Onebox.preview('https://www.youtube.com/watch?v=wi2jAtpBl0Y').placeholder_html)
preview.to match(/reacts/)
preview.to match(/hqdefault/)
end
And also added this at the beginning of the file, in before do: