// manualthumb? downstream behavior seems odd with
// missing manual thumbs.
$validated = true;
+ $value = $this->stripAltText( $value, $holders );
break;
case 'link':
$chars = self::EXT_LINK_URL_CLASS;
$params['frame']['caption'] = $caption;
- # Strip bad stuff out of the title (tooltip). We can't just use
- # replaceLinkHoldersText() here, because if this function is called
- # from replaceInternalLinks2(), mLinkHolders won't be up-to-date.
- if ( $holders ) {
- $tooltip = $holders->replaceText( $caption );
- } else {
- $tooltip = $this->replaceLinkHoldersText( $caption );
- }
-
- # make sure there are no placeholders in thumbnail attributes
- # that are later expanded to html- so expand them now and
- # remove the tags
- $tooltip = $this->mStripState->unstripBoth( $tooltip );
- $tooltip = Sanitizer::stripAllTags( $tooltip );
-
- $params['frame']['title'] = $tooltip;
+ $params['frame']['title'] = $this->stripAltText( $caption, $holders );
# In the old days, [[Image:Foo|text...]] would set alt text. Later it
# came to also set the caption, ordinary text after the image -- which
&& !isset( $params['frame']['framed'] )
&& !isset( $params['frame']['thumbnail'] )
&& !isset( $params['frame']['manualthumb'] ) ) {
- $params['frame']['alt'] = $tooltip;
+ $params['frame']['alt'] = $params['frame']['title'];
}
wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) );
return $ret;
}
+
+ protected function stripAltText( $caption, $holders ) {
+ # Strip bad stuff out of the title (tooltip). We can't just use
+ # replaceLinkHoldersText() here, because if this function is called
+ # from replaceInternalLinks2(), mLinkHolders won't be up-to-date.
+ if ( $holders ) {
+ $tooltip = $holders->replaceText( $caption );
+ } else {
+ $tooltip = $this->replaceLinkHoldersText( $caption );
+ }
+
+ # make sure there are no placeholders in thumbnail attributes
+ # that are later expanded to html- so expand them now and
+ # remove the tags
+ $tooltip = $this->mStripState->unstripBoth( $tooltip );
+ $tooltip = Sanitizer::stripAllTags( $tooltip );
+
+ return $tooltip;
+ }
/**
* Set a flag in the output object indicating that the content is dynamic and
!! end
+!! test
+Image with wiki markup in implicit alt
+!! input
+[[Image:Foobar.jpg|testing '''bold''' in alt]]
+!! result
+<p><a href="/wiki/Image:Foobar.jpg" class="image" title="testing bold in alt"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
+</p>
+!! end
+
+!! test
+Image with wiki markup in explicit alt
+!! input
+[[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
+!! result
+<p><a href="/wiki/Image:Foobar.jpg" class="image" title="Foobar.jpg"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
+</p>
+!! end
+
!! test
Link to image page- image page normally doesn't exists, hence edit link
Add test with existing image page