View Single Post
  #19  
Old 08-25-2016, 09:32 AM
ceptimus's Avatar
ceptimus ceptimus is offline
puzzler
 
Join Date: Aug 2004
Location: UK
Posts: XVMMDCCCXIX
Default Re: What's with the Youtubes

The $p1 is the first parameter recognized by the regex. $p2 would be the second parameter and so on - but in that screenshot you posted, only $p1 is used.

The $p1 parameter extracts the 'magic code' you see in a YouTube link. For example in this link:

https://youtu.be/z2GAmkradW8

the magic code is z2GAmkradW8 and in this iframe embed

<iframe width="420" height="315" src="https://www.youtube.com/embed/1LaCb0iEcOo" frameborder="0" allowfullscreen></iframe>

the magic code is 1LaCb0iEcOo

Note that the regex you posted wouldn't find the youtu.be link - it's only searching for the ones that have youtube.something

I think it's easier and probably better to go back to the old method where we ask the poster to manually cut and paste the magic code into a tag like

{youtube}magic code{/youtube} (except with square brackets instead of curly braces)

The tag code can then always use the iframe method - it doesn't matter whether the original link was youtu.be or youtube.com or something else - once you have the magic code you can always substitute it into the youtube.com iframe version.

To demonstrate I'll post he iframe method below (using youtube.com) for both the examples above and they should both work even though the first one originally was a youtu.be link. I can do this because I'm in the html group but once you've made (re-enabled ?) the tag it will work for everyone.





Quote this post to see how I did it. I used a couple of tricks with html entities to substitute some of the < / and . characters to stop the existing broken auto-parser mangling my post - but with the visible post and the quoted version you can see all that's needed.
__________________

Last edited by ceptimus; 08-25-2016 at 09:54 AM.
Reply With Quote
Thanks, from:
Ensign Steve (08-26-2016)
 
Page generated in 0.34012 seconds with 11 queries