MediaWiki REL1_39
PackedImageGallery.php
Go to the documentation of this file.
1<?php
24 public function __construct( $mode = 'traditional', IContextSource $context = null ) {
25 parent::__construct( $mode, $context );
26 // Does not support per row option.
27 $this->mPerRow = 0;
28 }
29
35 private const SCALE_FACTOR = 1.5;
36
37 protected function getVPad( $boxHeight, $thumbHeight ) {
38 return ( $this->getThumbPadding() + $boxHeight - $thumbHeight / self::SCALE_FACTOR ) / 2;
39 }
40
41 protected function getThumbPadding() {
42 return 0;
43 }
44
45 protected function getGBPadding() {
46 return 2;
47 }
48
53 protected function getThumbParams( $img ) {
54 if ( $img && $img->getMediaType() === MEDIATYPE_AUDIO ) {
55 $width = $this->mWidths;
56 } else {
57 // We want the width not to be the constraining
58 // factor, so use random big number.
59 $width = $this->mHeights * 10 + 100;
60 }
61
62 // self::SCALE_FACTOR so the js has some room to manipulate sizes.
63 return [
64 'width' => $width * self::SCALE_FACTOR,
65 'height' => $this->mHeights * self::SCALE_FACTOR,
66 ];
67 }
68
69 protected function getThumbDivWidth( $thumbWidth ) {
70 // Require at least 60px wide, so caption is wide enough to work.
71 if ( $thumbWidth < 60 * self::SCALE_FACTOR ) {
72 $thumbWidth = 60 * self::SCALE_FACTOR;
73 }
74
75 return $thumbWidth / self::SCALE_FACTOR + $this->getThumbPadding();
76 }
77
83 protected function getGBWidth( $thumb ) {
84 $thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR;
85
86 return $this->getThumbDivWidth( $thumbWidth ) + $this->getGBPadding();
87 }
88
89 protected function adjustImageParameters( $thumb, &$imageParameters ) {
90 // Re-adjust back to normal size.
91 $imageParameters['override-width'] = ceil( $thumb->getWidth() / self::SCALE_FACTOR );
92 $imageParameters['override-height'] = ceil( $thumb->getHeight() / self::SCALE_FACTOR );
93 }
94
100 protected function getModules() {
101 return [ 'mediawiki.page.gallery' ];
102 }
103
109 public function setPerRow( $num ) {
110 }
111}
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:32