FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » simple embed hack for youtube/polls/etc
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: simple embed hack for youtube/polls/etc [message #162517 is a reply to message #161885] Sun, 30 May 2010 14:58 Go to previous message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma:
Senior Member
I actually caved in and wrote a snip for youtube embedding. Embedding is slightly annoying though hehe, but i figured why the hell not.

The code looks like this and its ugly, very very ugly:

In the file DATA_ROOT/src/post_proc.inc.t

After the part that contains:
case 'wikipedia':
bla bla
break;

				case 'youtube':
					$url = substr($str, $epos+1, $cpos-1-$epos);
					
					$url = str_replace("/watch?v=","",$url);
					$url = str_replace("www.","",$url);
					$url = str_replace("http://","",$url);
					$url = str_replace("/v/","",$url);
					$url = str_replace("youtube.com","",$url);
					$url = substr($url, 0, strpos("$url&", "&"));
					$url = substr($url, 0, strpos("$url%", "%"));
					$ostr .= '<object width="720" height="480"><param name="movie" value="http://www.youtube.com/v/'.$url.'"></param><embed src="http://www.youtube.com/v/'.$url.'&amp;fs=1&amp;hd=1&amp;iv_load_policy=3&amp;color1=0x999999&amp;color2=0xF3F2E7" type="application/x-shockwave-flash"  allowscriptaccess="always" allowfullscreen="true" width="720" height="480"></embed></object>';
					$epos = $cepos;
					break;



and then after:
	array(
		'[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[s]', '[/s]', '[sub]', '[/sub]', '[sup]', '[/sup]', '[del]', '[/del]', 
		'[code]', '[/code]', '[align=center]', '[align=left]', '[align=right]', '[/align]', '[list]', '[/list]',
		'[notag]', '[/notag]', '[*]', '@', '://', '', '[pre]', '[/pre]','[hr]'
	),
	$fudml);

input
while (preg_match('!<object width="720" height="480"><param name="movie" value="(.*?)"></param><embed src="(.*?)" type="application/x-shockwave-flash"  allowscriptaccess="always" allowfullscreen="true" width="720" height="480"></embed></object>!is', $fudml)) {
		$fudml = preg_replace('!<object width="720" height="480"><param name="movie" value="(.*?)"></param><embed src="(.*?)" type="application/x-shockwave-flash"  allowscriptaccess="always" allowfullscreen="true" width="720" height="480"></embed></object>!is', '[youtube]\1[/youtube]', $fudml);
	}


[Updated on: Sun, 30 May 2010 14:58]

Report message to a moderator

[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ML/FUD Forum Gateway - Import archives of a mailing-list
Next Topic: New plugin call hook type & OpenID plugin
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 15:11:23 GMT 2024

Total time taken to generate the page: 0.06273 seconds