Index: maintenance/parserTests.txt =================================================================== --- maintenance/parserTests.txt (revision 19192) +++ maintenance/parserTests.txt (working copy) @@ -3520,6 +3520,15 @@ !! end !! test +Media link with fragment (bug 4198) +!! input +[[Media:Foobar.jpg#Page=3]] +!! result +
+!! end + +!! test Media link to nonexistent file (bug 1702) !! input [[Media:No such.jpg]] Index: includes/Linker.php =================================================================== --- includes/Linker.php (revision 19192) +++ includes/Linker.php (working copy) @@ -694,7 +694,7 @@ } else { $img = new Image( $title ); if( $img->exists() ) { - $url = $img->getURL(); + $url = $img->getURL() . $title->getFragmentForURL(); $class = 'internal'; } else { $upload = SpecialPage::getTitleFor( 'Upload' );