Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#24660 closed defect (bug) (fixed)

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

Reported by: designsimply's profile designsimply Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version:
Component: Embeds Keywords: has-patch
Focuses: Cc:


Steps to reproduce:

  1. Go to Posts > Add New
  2. Add this to its own line in the content area:
  3. Publish the post


Tested with WordPress trunk version 24528 on Bluehost

Should links like be working for oEmbed, or do you just need to make sure to use links like to avoid the problem?

Attachments (2)

24660_patch.diff (1.2 KB) - added by fahmiadib 10 years ago.
Patch added
24660.diff (1.6 KB) - added by wonderboymusic 10 years ago.

Download all attachments as: .zip

Change History (14)

#2 @ocean90
11 years 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.

#3 @designsimply
11 years 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 support which is why I created this ticket).

Aside: the long version of 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?

#4 @SergeyBiryukov
11 years ago

  • Keywords close removed

#5 @aaronholbrook
11 years 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.

#6 @wonderboymusic
11 years 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.

#7 @alexufo
10 years ago

this is not a bug. Youtube give two types url for users:
1) short:
2) and full:

link like yours
provided only for embed src in iframe or <object> tag and
not intended for use by users

#8 @designsimply
10 years ago

If it's not a bug, then it should be an enhancement ticket. :) I posted it because I saw support tickets from several users saying it was broken. Not a crazy high priority, but it seemed like something that could just be made to work nicely with popular types of URLs that users find and enter (even if they're doing it wrong).

#9 @wonderboymusic
10 years ago

  • Keywords needs-patch added; dev-feedback 2nd-opinion removed
  • Milestone changed from Awaiting Review to 4.0

I was about to close this, then I realized there is a slightly-relevant precedent with wp_embed_handler_googlevideo

Someone can patch this for 4.0, or we can decide that we aren't going to do anything

10 years ago

Patch added

#10 @fahmiadib
10 years ago

This patch should support embed/ and #/ for YouTube video links. Am i in the right direction here?

#11 @wonderboymusic
10 years ago

  • Keywords has-patch added; needs-patch removed

24660.diff fixes /embed/.* URLs and makes them to display watch?v=.* videos

#12 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28652:

Because of YouTube's overwhelming dominance in the online video space, we should help our users who paste bad URLs when possible. It is easy to fix URLs by turning them into embeds using an embed handler (we already have one to fix Google Video embeds).

We should avoid doing this in almost every other case, but it's YouTube, and it's an easy error for a novice to make.

Fixes #24660.

Note: See TracTickets for help on using tickets.