MediaWiki master
PackedImageGallery.php
Go to the documentation of this file.
1<?php
24
26 public function __construct( $mode = 'traditional', IContextSource $context = null ) {
27 parent::__construct( $mode, $context );
28 // Does not support per row option.
29 $this->mPerRow = 0;
30 }
31
37 private const SCALE_FACTOR = 1.5;
38
39 protected function getVPad( $boxHeight, $thumbHeight ) {
40 return ( $this->getThumbPadding() + $boxHeight - $thumbHeight / self::SCALE_FACTOR ) / 2;
41 }
42
43 protected function getThumbPadding() {
44 return 0;
45 }
46
47 protected function getGBPadding() {
48 return 2;
49 }
50
55 protected function getThumbParams( $img ) {
56 if ( $img && $img->getMediaType() === MEDIATYPE_AUDIO ) {
57 $width = $this->mWidths;
58 } else {
59 // We want the width not to be the constraining
60 // factor, so use random big number.
61 $width = $this->mHeights * 10 + 100;
62 }
63
64 // self::SCALE_FACTOR so the js has some room to manipulate sizes.
65 return [
66 'width' => (int)floor( $width * self::SCALE_FACTOR ),
67 'height' => (int)floor( $this->mHeights * self::SCALE_FACTOR ),
68 ];
69 }
70
71 protected function getThumbDivWidth( $thumbWidth ) {
72 // Require at least 60px wide, so caption is wide enough to work.
73 if ( $thumbWidth < 60 * self::SCALE_FACTOR ) {
74 $thumbWidth = 60 * self::SCALE_FACTOR;
75 }
76
77 return $thumbWidth / self::SCALE_FACTOR + $this->getThumbPadding();
78 }
79
85 protected function getGBWidth( $thumb ) {
86 $thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR;
87
88 return $this->getThumbDivWidth( $thumbWidth ) + $this->getGBPadding();
89 }
90
91 protected function adjustImageParameters( $thumb, &$imageParameters ) {
92 // Re-adjust back to normal size.
93 $imageParameters['override-width'] = ceil( $thumb->getWidth() / self::SCALE_FACTOR );
94 $imageParameters['override-height'] = ceil( $thumb->getHeight() / self::SCALE_FACTOR );
95 }
96
102 protected function getModules() {
103 return [ 'mediawiki.page.gallery' ];
104 }
105
111 public function setPerRow( $num ) {
112 }
113}
getThumbPadding()
How much padding the thumb has between the image and the inner div that contains the border.
getVPad( $boxHeight, $thumbHeight)
Get vertical padding for a thumbnail.
__construct( $mode='traditional', IContextSource $context=null)
Create a new image gallery object.
getModules()
Add javascript which auto-justifies the rows by manipulating the image sizes.
getThumbDivWidth( $thumbWidth)
Get the width of the inner div that contains the thumbnail in question.
setPerRow( $num)
Do not support per-row on packed.
adjustImageParameters( $thumb, &$imageParameters)
Adjust the image parameters for a thumbnail.
Interface for objects which can provide a MediaWiki context on request.
const MEDIATYPE_AUDIO
Definition defines.php:33