* add new hook LinkerMakeExternalImage to allow extensions to modify the HTML output...
authorRyan Schmidt <skizzerz@users.mediawiki.org>
Tue, 24 Jun 2008 14:32:49 +0000 (14:32 +0000)
committerRyan Schmidt <skizzerz@users.mediawiki.org>
Tue, 24 Jun 2008 14:32:49 +0000 (14:32 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/Linker.php

index 839f87e..54c13c4 100644 (file)
@@ -160,6 +160,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 14558) New system message (emailuserfooter) is now added to the footer of 
   e-mails sent with Special:Emailuser
 * Add support for Hijri (Islamic) calendar
+* Add a new hook LinkerMakeExternalImage to allow extensions to modify the output of
+  external (hotlinked) images.
   
 === Bug fixes in 1.13 ===
 
index 2357c65..c1475ac 100644 (file)
@@ -731,6 +731,11 @@ $lang: laguage code (string)
 $specialPageAliases: associative array of magic words synonyms
 $lang: laguage code (string)
 
+'LinkerMakeExternalImage': At the end of Linker::makeExternalImage() just before the return
+&$url: the image url
+&alt: the image's alt text
+&$img: the new image HTML (if returning false)
+
 'LinkerMakeExternalLink': At the end of Linker::makeExternalLink() just before the return
 &$url: the link url
 &$text: the link text
index 142cc5d..f64f9e4 100644 (file)
@@ -456,6 +456,12 @@ class Linker {
                if ( '' == $alt ) {
                        $alt = $this->fnamePart( $url );
                }
+               $img = '';
+               $success = wfRunHooks('LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
+               if(!$success) {
+                       wfDebug("Hook LinkerMakeExternalImage changed the output of external image with url {$url} and alt text {$alt} to {$img}", true);
+                       return $img;
+               }
                $s = '<img src="'.$url.'" alt="'.$alt.'" />';
                return $s;
        }