r82309 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82308‎ | r82309 | r82310 >
Date:23:21, 16 February 2011
Author:mah
Status:resolved (Comments)
Tags:
Comment:
followup r82181 and r82215 to fix the FIXME and botched fix for FIXME.
Patch supplied by DieBuche (bug #27338) along with screenshot
demonstrating fix.

Took out fix for bug #27458 (“<gallery> has a white background now”)
since bug it conflicts with a fix for bug #26470.
Modified paths:
  • /trunk/phase3/includes/ImageGallery.php (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImageGallery.php
@@ -275,7 +275,11 @@
276276 $thumbhtml = "\n\t\t\t".'<div style="height: '.(30 + $this->mHeights).'px;">'
277277 . htmlspecialchars( $img->getLastError() ) . '</div>';
278278 } else {
279 - $vpad = floor(( 30 + $this->mHeights - $thumb->height ) /2);
 279+ //We get layout problems with the margin, if the image is smaller
 280+ //than the line-height, so we less margin in these cases.
 281+ $minThumbHeight = $thumb->height > 17 ? $thumb->height : 17;
 282+ $vpad = floor(( 30 + $this->mHeights - $minThumbHeight ) /2);
 283+
280284
281285 $imageParameters = array(
282286 'desc-link' => true,
@@ -288,11 +292,11 @@
289293
290294 # Set both fixed width and min-height.
291295 $thumbhtml = "\n\t\t\t".
292 - '<div class="thumb" style="width: ' .($this->mWidths+30).'px; height: ' .($this->mHeights+30).'px;">'
 296+ '<div class="thumb" style="width: ' .($this->mWidths+30).'px;">'
293297 # Auto-margin centering for block-level elements. Needed now that we have video
294298 # handlers since they may emit block-level elements as opposed to simple <img> tags.
295299 # ref http://css-discuss.incutio.com/?page=CenteringBlockElement
296 - . '<div style="margin:'.$vpad.'px auto 0;">'
 300+ . '<div style="margin:'.$vpad.'px auto;">'
297301 . $thumb->toHtml( $imageParameters ) . '</div></div>';
298302
299303 // Call parser transform hook
Index: trunk/phase3/skins/common/shared.css
@@ -780,10 +780,6 @@
781781 margin: 2px;
782782 }
783783
784 -li.gallerybox div.thumb a.image img {
785 - vertical-align: text-top;
786 -}
787 -
788784 div.gallerytext {
789785 overflow: hidden;
790786 font-size: 94%;

Follow-up revisions

RevisionCommit summaryAuthorDate
r82735Fix Cite parser test for recent gallery changesoverlordq17:11, 24 February 2011
r85211MFT: r82297, r82307, r82309, r82312, r82315, r82337, r82391, r82392, r82403, ...demon21:01, 2 April 2011
r91426fixing rounding problem, per comment at r82309kaldari21:05, 4 July 2011
r91427better fix for bug 27338 - doesnt rely on line-heightkaldari21:30, 4 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82181* (bug 27338) Gallery in 1.17 breaks for audio/video + ogghandler...mah19:39, 15 February 2011
r82215re r82181 remove min-height that doesn't work with IE6mah03:38, 16 February 2011

Comments

#Comment by Kaldari (talk | contribs)   20:58, 4 July 2011

Due to the floor() rounding and odd-pixel tall thumbnail images, this code can result in thumb divs that are 1 pixel shorter than they are supposed to be. Using ceiling() would have the same problem but would result in thumbs that are 1 pixel too tall. There is no reason we need to round the value since I believe all modern browsers can properly deal with decimal margin values.

Also, I'm not sure relying on a 17px line-height is a good idea (or even accurate). The line-height within a thumb div is 1.5em which can be a variety of pixel heights. The default for me in Firefox is actually 19px.

#Comment by Kaldari (talk | contribs)   21:03, 4 July 2011

Sorry if it sounds like I'm blaming this rev for the rounding problem. Clearly it was introduced earlier, but we should go ahead and fix it anyway. Not sure what the best solution for the line-height problem is though.

#Comment by Kaldari (talk | contribs)   21:32, 4 July 2011

Implemented a better fix in r91427 that removes the line-height issue altogether.

#Comment by Kaldari (talk | contribs)   21:06, 4 July 2011

Fixed the rounding problem in r91426.

Status & tagging log