WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 23 months ago

#32714 closed defect (bug) (fixed)

oEmbed of m.youtube.com links don't render

Reported by: undergroundnetwork Owned by: wonderboymusic
Milestone: 4.3 Priority: normal
Severity: normal Version: 3.9
Component: Embeds Keywords: good-first-bug has-patch
Focuses: Cc:

Description

When a user is using a mobile phone to post to Wordpress, and they copy and paste a YouTube URL, YouTube changes the URLs of it's videos when accessed on a mobile phone by adding an m. before the URL, like: https://m.youtube.com/watch?v=yfUflij74P4

This results in Wordpress not recognizing that it is a YouTube URL and oEmbed does not render as a result.

This causes problems when using Press This as Press This grabs the URL which has an m. in it. This is a problem when a user has copied a YouTube URL on their phone (via the URL address bar, or the share menu on most phones) and they try to paste it into an article, because, again, YouTube puts that m. in the URL.

In order to make this work, perhaps a filter that removes the m. from YouTube URLs would help and the URLs could then render.

Attachments (2)

32714.patch (1.7 KB) - added by Toru 4 years ago.
Patch for oEmbed m.youtube.com
32714.tests.patch (915 bytes) - added by johnbillion 4 years ago.

Download all attachments as: .zip

Change History (17)

#1 @johnbillion
4 years ago

  • Keywords needs-patch needs-unit-tests good-first-bug added
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 4.2.2 to 3.9

#2 @johnbillion
4 years ago

  • Summary changed from oEmbed of YouTube links via mobile phones don't render. to oEmbed of m.youtube.com links don't render

#3 @johnbillion
4 years ago

Thanks for the report!

#4 @Toru
4 years ago

Interested to work on this bug. I will have a go.

@Toru
4 years ago

Patch for oEmbed m.youtube.com

#5 @Toru
4 years ago

I have attached a patch for wp-includes/class-oembed.php. It should now handle both www. and m..
I have found that code for PressThis in wp-admin/includes/class-wp-press-this.php already handles both www. and m. YouTube site.

#6 @johnbillion
4 years ago

  • Keywords has-patch added; needs-patch needs-unit-tests removed
  • Milestone changed from Future Release to 4.3

Thanks Toru. All looks good. 32714.tests.patch adds some tests.

#7 @wonderboymusic
4 years ago

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

In 32930:

YouTube oEmbed parsing: support the m subdomain.
Adds unit tests.

Props Toru, johnbillion.
Fixes #32714.

#8 @Toru
4 years ago

Thanks johnbillion, and wonderboymusic!
That was my first bug patch :-)

#9 follow-up: @undergroundnetwork
4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

This fix seems to no longer work, the mobile YouTube links no longer rendering again. This link does not render for example:

https://m.youtube.com/watch?feature=youtu.be&v=peVH0k0Hisc

Perhaps YouTube changed the format of their links?

Charles

Last edited 4 years ago by undergroundnetwork (previous) (diff)

#10 in reply to: ↑ 9 @ocean90
4 years ago

Replying to undergroundnetwork:

This fix seems to no longer work, the mobile YouTube links no longer rendering again. This link does not render for example:

https://m.youtube.com/watch?feature=youtu.be&v=peVH0k0Hisc

Which version are you testing? Your link seems to work for me:

var_dump( esc_html( wp_oembed_get( 'https://m.youtube.com/watch?feature=youtu.be&v=peVH0k0Hisc' ) ) );
// string(189) "<iframe width="660" height="371" src="https://www.youtube.com/embed/peVH0k0Hisc?feature=oembed" frameborder="0" allowfullscreen></iframe>"

#11 @undergroundnetwork
4 years ago

I'm running 4.2.4, the first test was on an iPad using Press This.

Oh wait! Is this not supposed to work until 4.3?? Did I just screw up?

If it is supposed to work, here is another example, I just took this YouTube link:

https://m.youtube.com/watch?feature=youtu.be&v=CDsNZJTWw0w

Pasted it into my new post and again it doesn't render.

I just ran it on a clean site, twenty12 theme, no plugins, but this link will render:

https://youtube.com/watch?feature=youtu.be&v=CDsNZJTWw0w

Again, if this is not supposed to work until 4.3 I apologize for reopening this again.

#12 @knutsp
4 years ago

  • Keywords close added

This ticket has milestone 4.3

#13 @helen
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

#14 @netweb
4 years ago

  • Keywords close removed

#15 @johnbillion
23 months ago

In 41712:

Embeds: Remove the external oEmbed tests for YouTube.

These tests no longer test anything that WordPress core has control over. YouTube now serves everything
over HTTPS by default, so the tests for #23149 will always pass, and the tests for #32714 aren't testing
anything that core has control over.

Tests for the responses from oEmbed providers has been attempted and reverted in #32360.

See #42076, #32714, #23149

Note: See TracTickets for help on using tickets.