Location: PHPKode > projects > BusinessWiki > extensions/BusinessWikiWidgets/YouTube.php
<?php

$wgExtensionFunctions[] = 'wfYouTube';
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'YouTube',
	'description' => 'Display YouTube video',
	'author' => 'Sylvain Machefert',
	'url' => 'http://www.mediawiki.org/wiki/Extension:YouTube_(Iubito)'
);
 
function wfYouTube() {
	global $wgParser;
	$wgParser->setHook( 'youtube', 'renderYouTube' );
}
 
function renderYouTube( $input, $params ) {
	$id = $params['id'];
    
	$width = !empty( $params['width'] ) ? $params['width'] : 425;
	$height = !empty( $params['height'] ) ? $params['height'] : 344;
 
	if ( preg_match('%[^A-Za-z0-9_\\-]%', $id ) ) {
		return 'YouTube : bad video ID !';
	}
 
	$url = 'http://www.youtube.com/v/' . $id;
	if ( 'high' == $params['quality'] ) {
	    // $url .= '%26ap=%2526fmt=18';
	}
	
	$output =
		Xml::openElement( 'object',
			array(
				'width' => $width,
				'height' => $height ) ) .
		Xml::openElement( 'param',
			array(
				'name' => 'movie',
				'value' => $url ) ) .
		'</param>' .
		Xml::openElement( 'embed',
			array(
				'src' => $url,
				'type' => 'application/x-shockwave-flash',
				'wmode' => 'transparent',
				'width' => $width,
				'height' => $height ) ) .
		'</embed>' .
		'</object>';

	return $output;
}
Return current item: BusinessWiki