Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

custom video plugin/function needed WordPress


I need a bit of a plugin, could be function (to paste in functions.php) which would in place of tag like:

[video width="400" height="300"]source url here[/video]

inject embed code for videoplayer.swf?width=400&height=400=src

I have a swf, I need only content parsing function.


Answers (2)


Utkarsh Kukreti answers:

function sc_video($atts, $content)
extract (shortcode_atts(array('width' => '400', 'height' => '300'),$atts));
$r = <<<OUT
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=",0,0,0" width="$width" height="$height">
<param name=movie value="$content?width=$width&height=$height"> <param name=quality value=high><embed src="$content?width=$width&height=$height" quality=high width="$width" height="$height" type="application/x-shockwave-flash"></embed> </object>
return $r;

add_shortcode('video', 'sc_video');



Lew Ayotte answers:

For this shortcode: [video width="400" height="300"]source url here[/video]

Try adding this to your functions.php:

// [video width='' height='']content[/video]
function video_func($atts, $content = null ) {
'width' => '400', //default, if not defined
'height' => '300', //default, if not defined
), $atts));

// use $content for the video source
// use {$width} for the width -- with the brackets
// use {$height} for the height -- with the brackets

$output = "your embed code with your new variables":

return $output;
add_shortcode('video', 'video_func');