--- HEAD\Linker.php Thu Jun 22 16:32:17 2006 +++ Linker.php Thu Jun 22 16:34:42 2006 @@ -919,7 +915,6 @@ # format regular and media links - all other wiki formatting # is ignored - $medians = $wgContLang->getNsText( NS_MEDIA ) . ':'; while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) { # Handle link renaming [[foo|text]] will show link as "text" if( "" != $match[3] ) { @@ -927,10 +922,22 @@ } else { $text = $match[1]; } - if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) { - # Media link; trail not supported. + if ($match[1][0] == ':') + $match[1] = substr($match[1], 1); + $title = Title::newFromText( $match[1] ); + $ns = $title->getNamespace(); + if ( $ns == NS_IMAGE || $ns == NS_MEDIA ) { + # Media link; trail not supported, special existence check. + $image = Image::newFromTitle( $title ); + if ( $image->exists() ) { + if ( $ns == NS_IMAGE ) + $thelink = $this->makeKnownLinkObj( $title, $text ); + else + $thelink = $this->makeMediaLinkObj( $title, $text ); + } else { + $thelink = $this->makeBrokenImageLinkObj( $title ); + } $linkRegexp = '/\[\[(.*?)\]\]/'; - $thelink = $this->makeMediaLink( $submatch[1], "", $text ); } else { # Other kind of link if( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) { @@ -939,9 +946,7 @@ $trail = ""; } $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/'; - if ($match[1][0] == ':') - $match[1] = substr($match[1], 1); - $thelink = $this->makeLink( $match[1], $text, "", $trail ); + $thelink = $this->makeLinkObj( $title, $text, "", $trail ); } $comment = preg_replace( $linkRegexp, wfRegexReplacement( $thelink ), $comment, 1 ); }