Page MenuHomePhabricator

ifexist.patch

Authored By
bzimport
Nov 21 2014, 9:27 PM
Size
768 B
Referenced Files
None
Subscribers
None

ifexist.patch

Index: extensions/ParserFunctions/ParserFunctions.php
===================================================================
--- extensions/ParserFunctions/ParserFunctions.php (revision 17981)
+++ extensions/ParserFunctions/ParserFunctions.php (arbetskopia)
@@ -163,6 +163,17 @@
function ifexist( &$parser, $title = '', $then = '', $else = '' ) {
$title = Title::newFromText( $title );
+
+ /* If namespace is specified as NS_MEDIA, then we want to check the physical file,
+ * not the "description" page.
+ */
+ if( $title->getNamespace() == NS_MEDIA ) {
+
+ $image = new Image( $title );
+ return is_object( $image ) && $image->exists() ? $then : $else;
+
+ }
+
return is_object( $title ) && $title->exists() ? $then : $else;
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2893
Default Alt Text
ifexist.patch (768 B)

Event Timeline