}
/** @deprecated use Linker::makeMediaLinkObj() */
- function makeMediaLink( $name, $unused = '', $text = '' ) {
+ function makeMediaLink( $name, $unused = '', $text = '', $time = false ) {
$nt = Title::makeTitleSafe( NS_IMAGE, $name );
- return $this->makeMediaLinkObj( $nt, $text );
+ return $this->makeMediaLinkObj( $nt, $text, $time );
}
/**
* Create a direct link to a given uploaded file.
*
* @param $title Title object.
- * @param $text String: pre-sanitized HTML
+ * @param $text String: pre-sanitized HTML
+ * @param $time string: time image was created
* @return string HTML
*
* @public
* @todo Handle invalid or missing images better.
*/
- function makeMediaLinkObj( $title, $text = '' ) {
+ function makeMediaLinkObj( $title, $text = '', $time = false ) {
if( is_null( $title ) ) {
### HOTFIX. Instead of breaking, return empty string.
return $text;
} else {
- $img = wfFindFile( $title );
+ $img = wfFindFile( $title, $time );
if( $img ) {
$url = $img->getURL();
$class = 'internal';
# Special and Media are pseudo-namespaces; no pages actually exist in them
if( $ns == NS_MEDIA ) {
- $link = $sk->makeMediaLinkObj( $nt, $text );
+ # Give extensions a chance to select the file revision for us
+ $skip = $time = false;
+ wfRunHooks( 'BeforeParserMakeImageLinkObj', array( &$this, &$nt, &$skip, &$time ) );
+ if ( $skip ) {
+ $link = $sk->makeLinkObj( $nt );
+ } else {
+ $link = $sk->makeMediaLinkObj( $nt, $text, $time );
+ }
# Cloak with NOPARSE to avoid replacement in replaceExternalLinks
$s .= $prefix . $this->armorLinks( $link ) . $trail;
$this->mOutput->addImage( $nt->getDBkey() );