Skip to content

Instantly share code, notes, and snippets.

@oremj
Created January 28, 2010 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oremj/289057 to your computer and use it in GitHub Desktop.
Save oremj/289057 to your computer and use it in GitHub Desktop.
<?php
$wgExtensionFunctions[] = 'efVideoSetUp';
function videoCreateAttrs($args) {
$attrs = array();
foreach($args as $key => $value) {
$attrs[] = sprintf('%s="%s"', $key, htmlspecialchars($value));
}
return implode(" ", $attrs);
}
function efVideoSetUp() {
global $wgParser;
$wgParser->setHook('video', 'efVideoRender');
$wgParser->setHook('source', 'efSourceRender');
return true;
}
function efVideoRender($input, $args, $parser, $frame) {
$output = $parser->recursiveTagParse($input, $frame);
return "<video " . videoCreateAttrs($args) . ">$output</video>";
}
function efSourceRender($input, $args, $parser, $frame) {
return "<source " . videoCreateAttrs($args) . "/>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment