Menu
Donate
Flattr
Paypal
Advertisement
Announcement: Due to massive spam attacks this page can only be edited by registered users. Sorry for this inconvenience.
Please add new code in this format
// Youtube Code
define("YOUTUBE_WIDTH", 545); // default width
define("YOUTUBE_HEIGHT", 440); // default height
define("YOUTUBE_REGEXP", "/\[youtube ([[:print:]]+)\]/");
define("YOUTUBE_TARGET", "<object type=\"application/x-shockwave-flash\" width=\"###WIDTH###\" height=\"###HEIGHT###\" data=\"http://www.youtube.com/v/###URL###&fs=1&rel=0&ap=%2526fmt%3D22&ap=%2526fmt%3D18\"><param name=\"movie\" value=\"http://www.youtube.com/v/###URL###&fs=1&rel=0&ap=%2526fmt%3D22&ap=%2526fmt%3D18\" /><param name=\"allowFullScreen\" value=\"true\" /></object>");
function youtube_plugin_callback($match)
{
$tag_parts = explode(" ", rtrim($match[0], "]"));
$output = YOUTUBE_TARGET;
$output = str_replace("###URL###", $tag_parts[1], $output);
if (count($tag_parts) > 2) {
if ($tag_parts[2] == 0) {
$output = str_replace("###WIDTH###", YOUTUBE_WIDTH, $output);
} else {
$output = str_replace("###WIDTH###", $tag_parts[2], $output);
}
if ($tag_parts[3] == 0) {
$output = str_replace("###HEIGHT###", YOUTUBE_HEIGHT, $output);
} else {
$output = str_replace("###HEIGHT###", $tag_parts[3], $output);
}
} else {
$output = str_replace("###WIDTH###", YOUTUBE_WIDTH, $output);
$output = str_replace("###HEIGHT###", YOUTUBE_HEIGHT, $output);
}
return ($output);
}
function youtube_plugin($content)
{
return (preg_replace_callback(YOUTUBE_REGEXP, 'youtube_plugin_callback', $content));
}
add_filter('the_content', 'youtube_plugin',1);
add_filter('the_content_rss', 'youtube_plugin');
add_filter('comment_text', 'youtube_plugin');
(sorry, I put it in the wishlist :P)
Hi, I had troubles resizing the videos from some sites because their callback function didn't support resizing, so I implemented a simple function on my blog to easily implement (hard-coded) resizing for any of the callback functions:
function v_plugin_callback($match,$codicehtml,$defaultwidth,$defaultheight) {
$tag_parts = explode(" ", rtrim($match[0], "]"));
$output = $codicehtml;
$output = str_replace("###URL###", $tag_parts[1], $output);
if (count($tag_parts) > 2) {
if ($tag_parts[2] == 0) {
$output = str_replace("###WIDTH###", $defaultwidth, $output);
} else {
$output = str_replace("###WIDTH###", $tag_parts[2], $output);
}
if ($tag_parts[3] == 0) {
$output = str_replace("###HEIGHT###", $defaultheight, $output);
} else {
$output = str_replace("###HEIGHT###", $tag_parts[3], $output);
}
} else {
$output = str_replace("###WIDTH###", $defaultwidth, $output);
$output = str_replace("###HEIGHT###", $defaultheight, $output);
}
return ($output);
}
So a callback function could be:
define("GameTrailers_WIDTH", 460);
define("GameTrailers_HEIGHT", 260);
define("GameTrailers_REGEXP", "/\[gametrailers ([[:print:]]+)\]/");
define("GameTrailers_TARGET", "<object id=\"gtembed\" width=\"".GameTrailers_WIDTH."\" height=\"".GameTrailers_HEIGHT."\">
<param name=\"movie\" value=\"http://www.gametrailers.com/remote_wrap.php?mid=###URL###\"/>
<param name=\"quality\" value=\"high\" />
<embed src=\"http://www.gametrailers.com/remote_wrap.php?mid=###URL###\" name=\"gtembed\" align=\"middle\" allowScriptAccess=\"sameDomain\" quality=\"high\" type=\"application/x-shockwave-flash\" width=\"###WIDTH###\" height=\"###HEIGHT###\"></embed> </object>");
function gametrailers_plugin_callback($match) {
return v_plugin_callback($match,GameTrailers_TARGET,GameTrailers_WIDTH,GameTrailers_HEIGHT);
}
function gametrailers_plugin($content) {^M
return preg_replace_callback(GameTrailers_REGEXP, 'gametrailers_plugin_callback', $content);
}
It would be very nice if you could include something like that by default. It would be very easy to add more sites, then. Tell me if you'd like some help (stmsat _@_ gmail.com).
Hey I found this code online (I don't remember were, and who write the code ), is usefull for embed Screentoaster video
//Screentoast Code
define("ST_WIDTH", 425); // default width
define("ST_HEIGHT", 344); // default height
define("ST_REGEXP", "/\[screentoaster ([[:print:]]+)\]/");
define("ST_TARGET", "<object width=\"###WIDTH###\" height=\"###HEIGHT###\" type=\"application/x-shockwave-flash\" data=\"http://www.screentoaster.com/swf/STPlayer.swf\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0\"><param name=\"movie\" value=\"http://www.screentoaster.com/swf/STPlayer.swf\"/><param name=\"allowFullScreen\" value=\"true\"/><param name=\"allowScriptAccess\" value=\"always\"/><param name='flashvars' value=\"video=###URL###\" /></object>");
function screentoaster_plugin_callback($match)
{
$tag_parts = explode(" ", rtrim($match[0], "]"));
$output = ST_TARGET;
$output = str_replace("###URL###", $tag_parts[1], $output);
if (count($tag_parts) > 2) {
if ($tag_parts[2] == 0) {
$output = str_replace("###WIDTH###", ST_WIDTH, $output);
} else {
$output = str_replace("###WIDTH###", $tag_parts[2], $output);
}
if ($tag_parts[3] == 0) {
$output = str_replace("###HEIGHT###", ST_HEIGHT, $output);
} else {
$output = str_replace("###HEIGHT###", $tag_parts[3], $output);
}
} else {
$output = str_replace("###WIDTH###", ST_WIDTH, $output);
$output = str_replace("###HEIGHT###", ST_HEIGHT, $output);
}
return ($output);
}
function screentoaster_plugin($content)
{
return (preg_replace_callback(ST_REGEXP, 'screentoaster_plugin_callback', $content));
}
add_filter('the_content', 'screentoaster_plugin',1);
add_filter('the_content_rss', 'screentoaster_plugin');
add_filter('comment_text', 'screentoaster_plugin');
Can you implement in the next release…
Bye Bye… Marcello