MediaWiki master
PackedImageGallery.php
Go to the documentation of this file.
1<?php
25
27 public function __construct( $mode = 'traditional', ?IContextSource $context = null ) {
28 parent::__construct( $mode, $context );
29 // Does not support per row option.
30 $this->mPerRow = 0;
31 }
32
38 private const SCALE_FACTOR = 1.5;
39
40 protected function getVPad( $boxHeight, $thumbHeight ) {
41 return ( $this->getThumbPadding() + $boxHeight - $thumbHeight / self::SCALE_FACTOR ) / 2;
42 }
43
44 protected function getThumbPadding() {
45 return 0;
46 }
47
48 protected function getGBPadding() {
49 return 2;
50 }
51
56 protected function getThumbParams( $img ) {
57 if ( $img && $img->getMediaType() === MEDIATYPE_AUDIO ) {
58 $width = $this->mWidths;
59 } else {
60 // We want the width not to be the constraining
61 // factor, so use random big number.
62 $width = $this->mHeights * 10 + 100;
63 }
64
65 // self::SCALE_FACTOR so the js has some room to manipulate sizes.
66 return [
67 'width' => (int)floor( $width * self::SCALE_FACTOR ),
68 'height' => (int)floor( $this->mHeights * self::SCALE_FACTOR ),
69 ];
70 }
71
72 protected function getThumbDivWidth( $thumbWidth ) {
73 // Require at least 60px wide, so caption is wide enough to work.
74 if ( $thumbWidth < 60 * self::SCALE_FACTOR ) {
75 $thumbWidth = 60 * self::SCALE_FACTOR;
76 }
77
78 return $thumbWidth / self::SCALE_FACTOR + $this->getThumbPadding();
79 }
80
86 protected function getGBWidth( $thumb ) {
87 $thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR;
88
89 return $this->getThumbDivWidth( $thumbWidth ) + $this->getGBPadding();
90 }
91
92 protected function adjustImageParameters( $thumb, &$imageParameters ) {
93 // Re-adjust back to normal size.
94 $imageParameters['override-width'] = ceil( $thumb->getWidth() / self::SCALE_FACTOR );
95 $imageParameters['override-height'] = ceil( $thumb->getHeight() / self::SCALE_FACTOR );
96 }
97
103 protected function getModules() {
104 return [ 'mediawiki.page.gallery' ];
105 }
106
112 public function setPerRow( $num ) {
113 }
114}
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition File.php:93
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.
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.
__construct( $mode='traditional', ?IContextSource $context=null)
Create a new image gallery object.
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