I'm trying to write a simple extension. I want to pass it the name of an uploaded media file but I can't seem to get it to the extension. Specifically, I don't want to have to put the path to the file in the call, I'd like to just put {{filepath:filename.ext}} and have the location found for me. I've stripped the extension down to just a few lines:
<?php $wgHooks['ParserFirstCallInit'][] = 'henryinit'; function henryinit( $parser ) { $parser->setHook( 'Henry', 'henryrender' ); return true; } function henryrender($input, $args) { global $wgScriptPath; return "File: ".$args['file']."<br>" ; } ?>
Then, in a page, I put the following (where GH-Scouts.mp4 is a previously uploaded video):
<henry width="400" height="300" file="{{filepath:GH-Scouts.mp4}}" /> Filepath: {{filepath:GH-Scouts.mp4}}
This returns the following:
File: {{filepath:GH-Scouts.mp4}} Filepath: http://www.mysite.com/images/a/ad/GH-Scouts.mp4
As you can see, the second line correctly displays the full path to the file but the first, which calls the extension, reports the file path as it was entered. I feel like I need to have my henryinit associated with a different hook but can't figure out which one. If, for instance, I use 'ParserBeforeTidy' it finds the path, but then it doesn't run my extension. Can someone point me to an example or discussion of how I can do this? Thanks.