For MediaWiki (recent comments | status changes | tags | authors | states | release notes)
Index: trunk/extensions/ImageMap/ImageMap_body.php =================================================================== --- trunk/extensions/ImageMap/ImageMap_body.php (revision 40683) +++ trunk/extensions/ImageMap/ImageMap_body.php (revision 40684) @@ -70,7 +70,33 @@ if ( wfIsBadImage( $imageTitle->getDBkey() , $parser->mTitle ) ) { return self::error( 'imagemap_bad_image' ); } - $imageHTML = $parser->makeImage( $imageTitle, Sanitizer::escapeHtmlAllowEntities($options) ); + // Parse the options so we can use links and the like in the caption, code adapted from Cite extension + if ( method_exists( $parser, 'recursiveTagParse' ) ) { + // New fast method + $parsedoptions = $parser->recursiveTagParse( Sanitizer::escapeHtmlAllowEntities($options) ); + } else { + // Old method + $ret = $parser->parse( + Sanitizer::escapeHtmlAllowEntities($options), + $parser->mTitle, + $parser->mOptions, + // Avoid whitespace buildup + false, + false + ); + $text = $ret->getText(); + global $wgUseTidy; + if ( ! $wgUseTidy ) + $parsedoptions = $text; + else { + $text = preg_replace( '~^<p>\s*~', '', $text ); + $text = preg_replace( '~\s*</p>\s*~', '', $text ); + $text = preg_replace( '~\n$~', '', $text ); + + $parsedoptions = $text; + } + } + $imageHTML = $parser->makeImage( $imageTitle, $parsedoptions ); $parser->mOutput->addImage( $imageTitle->getDBkey() ); $domDoc = new DOMDocument();