Page 2 of 2

Posted: Sun Apr 22, 2007 11:51 pm
by mrsander7x
I had a problem with whitespace around my embedded player. The following code takes care of that problem and adds an extra line at the beginning so you don't have to double space. The space before the <br /> is kinda sloppy but it takes care of the coding error you get if you try and insert a video at the very beginning of your post:

Code: Select all

$ret = preg_replace("#(^|[\n ]|<a(.*?)>)http://(www\.)?youtube\.com/watch\?v=([a-zA-Z0-9\-_]+)(</a>)?#im",' <br /><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$4"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$4" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><br /><a href="http://youtube.com/watch?v=$4" target="_blank">http://youtube.com/watch?v=$4</a>', $ret);
The following is the edited google video code (for convenience).

Code: Select all

$ret = preg_replace("#(^|[\n ]|<a(.*?)>)http://video.google.([a-z]+)/videoplay\?docid=([0-9\-_]+)(</a>)?#im",' <br /><embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.$3/googleplayer.swf?docId=$4"> </embed><br /><a href="http://video.google.$3/videoplay?docid=$4" target="_blank">http://video.google.$3/videoplay?docid=$4</a>', $ret);
Great job with the coding by the way. It works great!

please help me

Posted: Sat May 12, 2007 2:11 am
by robinkap
i use the code and the youtube video is work fine but i see the youtube URL code below the video player.

i dont want the URL is shown below the youtube player please tell me what i can do to hide the code

thnks in advance please help

Posted: Tue May 22, 2007 1:27 pm
by madthumbs
@robinkap
Try this instead:

Code: Select all

$ret = preg_replace("#(^|[\n ]|<a(.*?)>)http://(www\.)?youtube\.com/watch\?v=([a-zA-Z0-9\-_]+)(</a>)?#im",' <br /><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$4"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$4" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><br />', $ret);

Posted: Fri Jul 06, 2007 3:32 pm
by CadmanF
Hello, I've got a question but first I wanna say that this works great..!!

But my question, how can I adjust the codes so it will also work on Dutch YouTube movies like this one..:

http://nl.youtube.com/watch?v=iAev4_hfplI

Thanks in forward,

Frank

Posted: Fri Jul 06, 2007 3:38 pm
by madthumbs
@CadmanF

Try this:

Code: Select all

$ret = preg_replace("#(^|[\n ]|<a(.*?)>)http://(www\.)?([a-z]+)?youtube\.com/watch\?v=([a-zA-Z0-9\-_]+)(</a>)?#im",' <br /><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$5"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$5" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><br />', $ret);
Haven't tried it, not sure it will work and don't even know any php other than some stuff I figured out in this code. Back up your file before trying.

Posted: Fri Jul 06, 2007 4:08 pm
by CadmanF
Sorry, it doesn't work... :cry:

Maybe another idear..?

The only thing I have manually change in the code so the Mod will recognize it is..:

From the original link..:

http://nl.youtube.com/watch?v=iAev4_hfplI

Remove nl. and replace it with www. and it works...

http://www.youtube.com/watch?v=iAev4_hfplI

On my forum...

So how can it probably changed in the Mod code... :?:

Posted: Fri Aug 17, 2007 2:28 pm
by sarge
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi will this mod work in phpnuke. i have inserted the code but it does not work. I have no dout its someting i have done wrong!
Here's The code..

Code: Select all

* Rewritten by Nathan Codding - Feb 6, 2001.
 * - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking
 * 	to that URL
 * - Goes through the given string, and replaces http://www.xxxx.yyyy[zzzz] with an HTML <a> tag linking
 * 	to http://www.xxxx.yyyy[/zzzz]
 * - Goes through the given string, and replaces xxxx@yyyy with an HTML mailto: tag linking
 *		to that email address
 * - Only matches these 2 patterns either after a space, or at the beginning of a line
 *
 * Notes: the email one might get annoying - it's easy to make it more restrictive, though.. maybe
 * have it require something like xxxx@yyyy.zzzz or such. We'll see.
 */
function make_clickable($text)
{
	$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);

	// pad it with a space so we can match things at the start of the 1st line.
	$ret = ' ' . $text;
	// youtube code.. 
        $ret = preg_replace("#(^|[\n ]|<a(.*?)>)http://(www\.)?youtube\.com/watch\?v=([a-zA-Z0-9\-_]+)(</a>)?#im",' <!-- BEGIN youtube --><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$4"></param><embed src="http://www.youtube.com/v/$4" type="application/x-shockwave-flash" width="425" height="350"></embed></object><br /><a href="http://youtube.com/watch?v=$4" target="_blank">http://youtube.com/watch?v=$4</a><!-- END youtube -->', $ret);

	// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
	// xxxx can only be alpha characters.
	// yyyy is anything up to the first space, newline, comma, double quote or <
	$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);

	// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
	// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
	// zzzz is optional.. will contain everything up to the first space, newline, 
	// comma, double quote or <.
	$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
Thanks for any help!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Aug 18, 2007 3:56 am
by sarge
Sorry about posting the code wrong im a bad boy! :nono:

Posted: Sun Aug 26, 2007 12:06 am
by Sebi_
Hi. Thank you for this code.
But why is no name of the video? like here:

http://img169.imageshack.us/img169/2494/youtubetx9.jpg

Re: youtube auto-embedding for phpBB

Posted: Sat Feb 02, 2008 2:06 am
by moonmoon
well~THANKS.

Re: youtube auto-embedding for phpBB

Posted: Tue Mar 25, 2008 8:45 am
by Snow123
i dont want the URL is shown below the youtube player please tell me what i can do to hide the code! :wink:

thnks in advance please help. :offtopic: