Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If youtube video address has "feature=player_embedded&" in it, video does not displays. Example:
[video:http://www.youtube.com/watch?feature=player_embedded&v=jzmXhe5Ssrk]
Comment | File | Size | Author |
---|---|---|---|
#11 | video_filter-youtube-feature-1400794-11.patch | 566 bytes | Ken Hawkins |
Comments
Comment #1
mr.alinaki CreditAttribution: mr.alinaki commentedAnd here comes the fix!
'/youtube\.com\/watch\?(?:feature=player_embedded\&)?v=([a-z0-9\-_]+)(?:\&feature=player_embedded)?/i'
Comment #2
blackdog CreditAttribution: blackdog commentedWhere do you get an URL like that?
Comment #3
kmontyI agree that this is a common issue with content editors. YouTube videos are often grabbed from videos embedded on other sites, and when you click the link within the embed, it attaches a "filtered" query to the video.
+1 on fixing.
Comment #4
drupik CreditAttribution: drupik commented@mr.alinaki - nice one song :D
Comment #5
blackdog CreditAttribution: blackdog commentedI'm in favor of fixing it, but the regexp in #1 doesn't work.
Comment #6
TravisCarden CreditAttribution: TravisCarden commentedWhat about this?
youtube\.com\/watch\?(([a-z0-9%*\-_.]+=[a-z0-9%*\-_.]+)+&)*(v=[a-z0-9%*\-_.]+)(&([a-z0-9%*\-_.]+=[a-z0-9%*\-_.]+))*
This would match any valid query string containing
v=whatever
. That way you don't have to know all the valid variables (or account for new ones when they're added to the API in the future). It breaks down like this:youtube.com/watch?
var=val&
v=whatever
&var=val
Comment #7
mherchelThis is a very common use case.
I tried adding the regex from #1 and #6 into new lines within video_filter.codecs.inc, and also tried replacing line with it.
It didn't work though. The URL that I'm trying to get to work is
http://www.youtube.com/watch?feature=player_embedded&v=UDMUyhNJhi8
Comment #8
Martijn Houtman CreditAttribution: Martijn Houtman commented/youtube\.com\/watch\?(?:[\w]+=[\w]+\&)*v=([a-z0-9\-_]+)(?:[\w]+=[\w]+\&)*/i
More robust and matches the above cases.
Comment #9
Martijn Houtman CreditAttribution: Martijn Houtman commentedTypo, it should read:
/youtube\.com\/watch\?(?:[\w]+=[\w]+\&)*v=([a-z0-9\-_]+)(?:\&[\w]+=[\w]+)*/i
Comment #10
Martijn Houtman CreditAttribution: Martijn Houtman commentedOK, I just ran into this URL: http://www.youtube.com/watch?feature=g-all-esi&v=Ln5K3_8Cxrc
So the regex should read:
/youtube\.com\/watch\?(?:[\w-]+=[\w-]+\&)*v=([a-z0-9\-_]+)(?:\&[\w-]+=[\w-]+)*/i
My list two cents for now :-)
Comment #11
Ken Hawkins CreditAttribution: Ken Hawkins commentedThe regexs listed before likely weren't working with WYSIWYGs as the "&" is converted to "
&
"Updated the regex from #10 to:
Adds the optional detection of
(?:amp;)
Things are working well for us now.
Patch attached.
Comment #12
kmontyComment #13
DamienMcKennaAdding this to the proposed issues list for the 3.2 release.
Comment #14
DamienMcKennaActually I'm going to close this in favor of #2030795: Allow more flexible Youtube URLs which also adds support for youtube.com/embed URLs.