* Introduce 'BadImage' hook; see docs/hooks.txt for more information
authorRob Church <robchurch@users.mediawiki.org>
Sun, 2 Jul 2006 21:54:34 +0000 (21:54 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sun, 2 Jul 2006 21:54:34 +0000 (21:54 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/ImageFunctions.php

index 809e00b..a0ae8d9 100644 (file)
@@ -632,6 +632,7 @@ Some default configuration options have changed:
 * Rename "searchquery" to "searchsubtitle" and support wiki text in it
 * Introduce updateArticleCount maintenance script which uses a better check that
   reflects what Article::isCountable() tests for
+* Introduce 'BadImage' hook; see docs/hooks.txt for more information
 
 == Compatibility ==
 
index 2e7db30..4dd68f5 100644 (file)
@@ -289,6 +289,13 @@ $section: section #
 'AutoAuthenticate': called to authenticate users on external/environmental means
 $user: writes user object to this parameter
 
+'BadImage': When checking against the bad image list
+$name: Image name being checked
+&$bad: Whether or not the image is "bad"
+
+Change $bad and return false to override. If an image is "bad", it is not
+rendered inline in wiki pages or galleries in category pages.
+
 'BlockIp': before an IP address or user is blocked
 $block: the Block object about to be saved
 $user: the user _doing_ the block (not the one being blocked)
index c031d7e..691d7c9 100644 (file)
@@ -217,20 +217,27 @@ function wfGetSVGsize( $filename ) {
  */\r
 function wfIsBadImage( $name ) {\r
        static $titleList = false;\r
-       \r
-       if( !$titleList ) {\r
-               # Build the list now\r
-               $titleList = array();\r
-               $lines = explode( "\n", wfMsgForContent( 'bad_image_list' ) );\r
-               foreach( $lines as $line ) {\r
-                       if( preg_match( '/^\*\s*\[\[:?(.*?)\]\]/i', $line, $matches ) ) {\r
-                               $title = Title::newFromText( $matches[1] );\r
-                               if( is_object( $title ) && $title->getNamespace() == NS_IMAGE )\r
-                                       $titleList[ $title->getDBkey() ] = true;\r
+       wfProfileIn( __METHOD__ );\r
+       $bad = false;\r
+       if( wfRunHooks( 'BadImage', array( $name, &$bad ) ) {\r
+               if( !$titleList ) {\r
+                       # Build the list now\r
+                       $titleList = array();\r
+                       $lines = explode( "\n", wfMsgForContent( 'bad_image_list' ) );\r
+                       foreach( $lines as $line ) {\r
+                               if( preg_match( '/^\*\s*\[\[:?(.*?)\]\]/i', $line, $matches ) ) {\r
+                                       $title = Title::newFromText( $matches[1] );\r
+                                       if( is_object( $title ) && $title->getNamespace() == NS_IMAGE )\r
+                                               $titleList[ $title->getDBkey() ] = true;\r
+                               }\r
                        }\r
                }\r
+               wfProfileOut( __METHOD__ );\r
+               return array_key_exists( $name, $titleList );\r
+       } else {\r
+               wfProfileOut( __METHOD__ );\r
+               return $bad;\r
        }\r
-       return array_key_exists( $name, $titleList );\r
 }\r
 \r
 /**\r