From: Aryeh Gregor Date: Sun, 28 Sep 2008 21:07:34 +0000 (+0000) Subject: (bug 368) Allow alt= attribute for images X-Git-Tag: 1.31.0-rc.0~45032 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=a53fa1decdcf6a2754b8017e258e8328c49546cb;p=lhc%2Fweb%2Fwiklou.git (bug 368) Allow alt= attribute for images If the attribute is not specified, default to empty string, not repeating the caption. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ace79ce354..483b61b514 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -146,6 +146,8 @@ The following extensions are migrated into MediaWiki 1.14: $wgExternalLinkTarget * (bug 674) Allow admins to block users from editing specific articles and namespaces +* (bug 368) Don't use caption for alt attribute; allow manual specification + using new "alt=" parameter for images === Bug fixes in 1.14 === diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 9e8ed0cecb..8687091631 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4186,7 +4186,7 @@ class Parser 'vertAlign' => array( 'baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom' ), 'frame' => array( 'thumbnail', 'manualthumb', 'framed', 'frameless', - 'upright', 'border' ), + 'upright', 'border', 'alt' ), ); static $internalParamMap; if ( !$internalParamMap ) { @@ -4222,16 +4222,17 @@ class Parser function makeImage( $title, $options, $holders = false ) { # Check if the options text is of the form "options|alt text" # Options are: - # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang - # * left no resizing, just left align. label is used for alt= only - # * right same, but right aligned - # * none same, but not aligned - # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox - # * center center the image - # * framed Keep original image size, no magnify-button. - # * frameless like 'thumb' but without a frame. Keeps user preferences for width - # * upright reduce width for upright images, rounded to full __0 px - # * border draw a 1px border around the image + # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang + # * left no resizing, just left align. label is used for alt= only + # * right same, but right aligned + # * none same, but not aligned + # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox + # * center center the image + # * framed Keep original image size, no magnify-button. + # * frameless like 'thumb' but without a frame. Keeps user preferences for width + # * upright reduce width for upright images, rounded to full __0 px + # * border draw a 1px border around the image + # * alt Text for HTML alt attribute (defaults to empty) # vertical-align values (no % or length right now): # * baseline # * sub @@ -4300,7 +4301,8 @@ class Parser } else { # Validate internal parameters switch( $paramName ) { - case "manualthumb": + case 'manualthumb': + case 'alt': /// @fixme - possibly check validity here? /// downstream behavior seems odd with missing manual thumbs. $validated = true; @@ -4329,22 +4331,6 @@ class Parser $params['frame']['valign'] = key( $params['vertAlign'] ); } - # Strip bad stuff out of the alt text - # We can't just use replaceLinkHoldersText() here, because if this function - # is called from replaceInternalLinks2(), mLinkHolders won't be up to date. - if ( $holders ) { - $alt = $holders->replaceText( $caption ); - } else { - $alt = $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 - $alt = $this->mStripState->unstripBoth( $alt ); - $alt = Sanitizer::stripAllTags( $alt ); - - $params['frame']['alt'] = $alt; $params['frame']['caption'] = $caption; wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index dad954ce42..5a2bbf6950 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -287,6 +287,7 @@ $magicWords = array( 'img_middle' => array( 1, 'middle' ), 'img_bottom' => array( 1, 'bottom' ), 'img_text_bottom' => array( 1, 'text-bottom' ), + 'img_alt' => array( 1, 'alt=$1', 'alt $1' ), 'int' => array( 0, 'INT:' ), 'sitename' => array( 1, 'SITENAME' ), 'ns' => array( 0, 'NS:' ),