Make WordPress Core

Opened 10 months ago

Last modified 9 months ago

#24660 new defect (bug)

YouTube oEmbeds don't work for full-width YouTube video links

Reported by: designsimply Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Embeds Keywords: dev-feedback 2nd-opinion
Focuses: Cc:


Steps to reproduce:

  1. Go to Posts > Add New
  2. Add this to its own line in the content area: http://www.youtube.com/embed/8N_tupPBtWQ
  3. Publish the post

Screencast: http://screencast.com/t/nMCYr3N3uF

Tested with WordPress trunk version 24528 on Bluehost

Should links like http://www.youtube.com/embed/tgbNymZ7vqY be working for oEmbed, or do you just need to make sure to use links like http://www.youtube.com/watch?v=tgbNymZ7vqY to avoid the problem?

Change History (6)

comment:1 SergeyBiryukov10 months ago

Looks like YouTube oEmbed endpoint only works for /watch?v=... links.

This works:


This returns a 404 error:

Version 0, edited 10 months ago by SergeyBiryukov (next)

comment:2 ocean9010 months ago

  • Keywords close added

The src of the returned iframe from the oEmbed endpoint contains the embed part. You should just use the links, which YouTube gives you.

comment:3 designsimply10 months ago

I think users tend to copy out the URL from the Share > Embed section on YouTube pages, and that's what gets them confused (it gets reported from time to time in WP.com support which is why I created this ticket).

Aside: the long version of youtube.com mobile URLs have the same problem. If you are on a mobile device such as an iPad and copy the URL directly from a YouTube page, the link will not auto embed. Example link:

In contrast, auto embeds for the short version of mobile URLs worked fine in my tests:

Tested with WP trunk r24579 on Bluehost + Twenty Thirteen theme.

To fix both the "/embed/" URL and the mobile URL issues, could the unique identifier (such as "tgbNymZ7vqY") be pulled out and then used in whatever oEmbed URL structure is supported?

comment:4 SergeyBiryukov10 months ago

  • Keywords close removed

comment:5 aaronholbrook9 months ago

  • Keywords dev-feedback 2nd-opinion added

I tend to agree with designsimply, this may be something we wish to do simply to make the user experience that much more intuitive and simple, especially if people are having an issue copying out the URL on mobile.

I am +1 to implementing this change, but would like some dev-feedback and a second opinion on this matter.

comment:6 wonderboymusic9 months ago

If you go to Share > Embed, it gives you the <iframe> code to paste in - using the src from there is a you-break-it-you-bought-it situation. The /embed/ and mobile with # would have to be new YouTube oEmbed providers in WP, but would need additional hacks to turn /embed/ into /watch?v=. Might be best tackled in pre_kses or something.

Jetpack does all kinds of crazy stuff to YouTube URLs. I actually turned off most of what it does on a site I am building, but for these scenarios, there is probably some useful code in there.

Note: See TracTickets for help on using tickets.