Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -6732,7 +6732,7 @@ |
6733 | 6733 | image:foobar.jpg |
6734 | 6734 | </gallery> |
6735 | 6735 | !! result |
6736 | | -<ul class="gallery" style="max-width: 220px;_width: 220px;"> |
| 6736 | +<ul class="gallery" style="max-width: 202px;_width: 202px;"> |
6737 | 6737 | <li class='gallerycaption'>Foo <a href="https://www.mediawiki.org/wiki/Main_Page">Main Page</a></li> |
6738 | 6738 | <li class="gallerybox" style="width: 95px"><div style="width: 95px"> |
6739 | 6739 | <div style="height: 70px;">Nonexistant.jpg</div> |
Index: trunk/phase3/includes/ImageGallery.php |
— | — | @@ -35,6 +35,13 @@ |
36 | 36 | private $mAttribs = array(); |
37 | 37 | |
38 | 38 | /** |
| 39 | + * Fixed margins |
| 40 | + */ |
| 41 | + const THUMB_PADDING = 30; |
| 42 | + const GB_PADDING = 5; |
| 43 | + const GB_BORDERS = 6; |
| 44 | + |
| 45 | + /** |
39 | 46 | * Create a new image gallery object. |
40 | 47 | */ |
41 | 48 | function __construct( ) { |
— | — | @@ -226,7 +233,7 @@ |
227 | 234 | $sk = $this->getSkin(); |
228 | 235 | |
229 | 236 | if ( $this->mPerRow > 0 ) { |
230 | | - $maxwidth = $this->mPerRow * ( $this->mWidths + 50 ); |
| 237 | + $maxwidth = $this->mPerRow * ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS ); |
231 | 238 | $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ""; |
232 | 239 | $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle; |
233 | 240 | } |
— | — | @@ -258,11 +265,11 @@ |
259 | 266 | |
260 | 267 | if( !$img ) { |
261 | 268 | # We're dealing with a non-image, spit out the name and be done with it. |
262 | | - $thumbhtml = "\n\t\t\t".'<div style="height: '.(30 + $this->mHeights).'px;">' |
| 269 | + $thumbhtml = "\n\t\t\t".'<div style="height: '.(self::THUMB_PADDING + $this->mHeights).'px;">' |
263 | 270 | . htmlspecialchars( $nt->getText() ) . '</div>'; |
264 | 271 | } elseif( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) { |
265 | 272 | # The image is blacklisted, just show it as a text link. |
266 | | - $thumbhtml = "\n\t\t\t".'<div style="height: '.(30 + $this->mHeights).'px;">' . |
| 273 | + $thumbhtml = "\n\t\t\t".'<div style="height: '.(self::THUMB_PADDING + $this->mHeights).'px;">' . |
267 | 274 | $sk->link( |
268 | 275 | $nt, |
269 | 276 | htmlspecialchars( $nt->getText() ), |
— | — | @@ -273,13 +280,13 @@ |
274 | 281 | '</div>'; |
275 | 282 | } elseif( !( $thumb = $img->transform( $params ) ) ) { |
276 | 283 | # Error generating thumbnail. |
277 | | - $thumbhtml = "\n\t\t\t".'<div style="height: '.(30 + $this->mHeights).'px;">' |
| 284 | + $thumbhtml = "\n\t\t\t".'<div style="height: '.(self::THUMB_PADDING + $this->mHeights).'px;">' |
278 | 285 | . htmlspecialchars( $img->getLastError() ) . '</div>'; |
279 | 286 | } else { |
280 | 287 | //We get layout problems with the margin, if the image is smaller |
281 | 288 | //than the line-height, so we less margin in these cases. |
282 | 289 | $minThumbHeight = $thumb->height > 17 ? $thumb->height : 17; |
283 | | - $vpad = floor(( 30 + $this->mHeights - $minThumbHeight ) /2); |
| 290 | + $vpad = floor(( self::THUMB_PADDING + $this->mHeights - $minThumbHeight ) /2); |
284 | 291 | |
285 | 292 | |
286 | 293 | $imageParameters = array( |
— | — | @@ -293,7 +300,7 @@ |
294 | 301 | |
295 | 302 | # Set both fixed width and min-height. |
296 | 303 | $thumbhtml = "\n\t\t\t". |
297 | | - '<div class="thumb" style="width: ' .($this->mWidths+30).'px;">' |
| 304 | + '<div class="thumb" style="width: ' .($this->mWidths + self::THUMB_PADDING).'px;">' |
298 | 305 | # Auto-margin centering for block-level elements. Needed now that we have video |
299 | 306 | # handlers since they may emit block-level elements as opposed to simple <img> tags. |
300 | 307 | # ref http://css-discuss.incutio.com/?page=CenteringBlockElement |
— | — | @@ -339,8 +346,8 @@ |
340 | 347 | # Weird double wrapping in div needed due to FF2 bug |
341 | 348 | # Can be safely removed if FF2 falls completely out of existance |
342 | 349 | $s .= |
343 | | - "\n\t\t" . '<li class="gallerybox" style="width: ' . ( $this->mWidths + 35 ) . 'px">' |
344 | | - . '<div style="width: ' . ( $this->mWidths + 35 ) . 'px">' |
| 350 | + "\n\t\t" . '<li class="gallerybox" style="width: ' . ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING ) . 'px">' |
| 351 | + . '<div style="width: ' . ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING ) . 'px">' |
345 | 352 | . $thumbhtml |
346 | 353 | . "\n\t\t\t" . '<div class="gallerytext">' . "\n" |
347 | 354 | . $textlink . $text . $nb |