r41407 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41406‎ | r41407 | r41408 >
Date:00:21, 30 September 2008
Author:brion
Status:old
Tags:
Comment:
Revert r41364 -- broke 22 parser test cases with change of alt behavior.

The caption was originally defined *as* the alt text (defaulting to the image file name if there is no alt text). Note that a separate caption text is only displayed in some display modes ('frame' and 'thumb', iirc), and not by default.

Please run the parser tests and check the effect you have on them. If it's really an appropriate change, then update the test cases. If you're not sure, consider backing out pending further discussion. :)

It might be appropriate to not set the 'alt' attribute for frame/thumb cases, but definitely not for inline images where we already have a way of setting the alt text which you're removing!
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -4164,7 +4164,7 @@
41654165 'vertAlign' => array( 'baseline', 'sub', 'super', 'top', 'text-top', 'middle',
41664166 'bottom', 'text-bottom' ),
41674167 'frame' => array( 'thumbnail', 'manualthumb', 'framed', 'frameless',
4168 - 'upright', 'border', 'alt' ),
 4168+ 'upright', 'border' ),
41694169 );
41704170 static $internalParamMap;
41714171 if ( !$internalParamMap ) {
@@ -4200,17 +4200,16 @@
42014201 function makeImage( $title, $options, $holders = false ) {
42024202 # Check if the options text is of the form "options|alt text"
42034203 # Options are:
4204 - # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
4205 - # * left no resizing, just left align. label is used for alt= only
4206 - # * right same, but right aligned
4207 - # * none same, but not aligned
4208 - # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
4209 - # * center center the image
4210 - # * framed Keep original image size, no magnify-button.
4211 - # * frameless like 'thumb' but without a frame. Keeps user preferences for width
4212 - # * upright reduce width for upright images, rounded to full __0 px
4213 - # * border draw a 1px border around the image
4214 - # * alt Text for HTML alt attribute (defaults to empty)
 4204+ # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
 4205+ # * left no resizing, just left align. label is used for alt= only
 4206+ # * right same, but right aligned
 4207+ # * none same, but not aligned
 4208+ # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
 4209+ # * center center the image
 4210+ # * framed Keep original image size, no magnify-button.
 4211+ # * frameless like 'thumb' but without a frame. Keeps user preferences for width
 4212+ # * upright reduce width for upright images, rounded to full __0 px
 4213+ # * border draw a 1px border around the image
42154214 # vertical-align values (no % or length right now):
42164215 # * baseline
42174216 # * sub
@@ -4279,8 +4278,7 @@
42804279 } else {
42814280 # Validate internal parameters
42824281 switch( $paramName ) {
4283 - case 'manualthumb':
4284 - case 'alt':
 4282+ case "manualthumb":
42854283 /// @fixme - possibly check validity here?
42864284 /// downstream behavior seems odd with missing manual thumbs.
42874285 $validated = true;
@@ -4309,6 +4307,22 @@
43104308 $params['frame']['valign'] = key( $params['vertAlign'] );
43114309 }
43124310
 4311+ # Strip bad stuff out of the alt text
 4312+ # We can't just use replaceLinkHoldersText() here, because if this function
 4313+ # is called from replaceInternalLinks2(), mLinkHolders won't be up to date.
 4314+ if ( $holders ) {
 4315+ $alt = $holders->replaceText( $caption );
 4316+ } else {
 4317+ $alt = $this->replaceLinkHoldersText( $caption );
 4318+ }
 4319+
 4320+ # make sure there are no placeholders in thumbnail attributes
 4321+ # that are later expanded to html- so expand them now and
 4322+ # remove the tags
 4323+ $alt = $this->mStripState->unstripBoth( $alt );
 4324+ $alt = Sanitizer::stripAllTags( $alt );
 4325+
 4326+ $params['frame']['alt'] = $alt;
43134327 $params['frame']['caption'] = $caption;
43144328
43154329 wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) );
Index: trunk/phase3/RELEASE-NOTES
@@ -140,8 +140,6 @@
141141 restriction types on the protection form.
142142 * (bug 8440) Allow preventing blocked users from editing their talk pages
143143 * Improved upload file type detection for OpenDocument formats
144 -* (bug 368) Don't use caption for alt attribute; allow manual specification
145 - using new "alt=" parameter for images
146144
147145
148146 === Bug fixes in 1.14 ===
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -287,7 +287,6 @@
288288 'img_middle' => array( 1, 'middle' ),
289289 'img_bottom' => array( 1, 'bottom' ),
290290 'img_text_bottom' => array( 1, 'text-bottom' ),
291 - 'img_alt' => array( 1, 'alt=$1', 'alt $1' ),
292291 'int' => array( 0, 'INT:' ),
293292 'sitename' => array( 1, 'SITENAME' ),
294293 'ns' => array( 0, 'NS:' ),

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41364(bug 368) Allow alt= attribute for images...simetrical21:07, 28 September 2008

Status & tagging log