MediaWiki
master
Toggle main menu visibility
PackedImageGallery.php
Go to the documentation of this file.
1
<?php
6
7
namespace
MediaWiki\Gallery;
8
9
use MediaWiki\Context\IContextSource;
10
use MediaWiki\FileRepo\File\File;
11
use MediaWiki\Media\MediaTransformOutput;
12
16
class
PackedImageGallery
extends
TraditionalImageGallery
{
18
public
function
__construct
( $mode =
'traditional'
, ?
IContextSource
$context =
null
) {
19
parent::__construct( $mode, $context );
20
// Does not support per row option.
21
$this->mPerRow = 0;
22
}
23
29
private
const
SCALE_FACTOR = 1.5;
30
32
protected
function
getVPad
( $boxHeight, $thumbHeight ) {
33
return
( $this->
getThumbPadding
() + $boxHeight - $thumbHeight / self::SCALE_FACTOR ) / 2;
34
}
35
37
protected
function
getThumbPadding
() {
38
return
0;
39
}
40
42
protected
function
getGBPadding
() {
43
return
2;
44
}
45
50
protected
function
getThumbParams
( $img ) {
51
if
( $img && $img->getMediaType() ===
MEDIATYPE_AUDIO
) {
52
$width =
$this->mWidths
;
53
}
else
{
54
// We want the width not to be the constraining
55
// factor, so use random big number.
56
$width = $this->mHeights * 10 + 100;
57
}
58
59
// self::SCALE_FACTOR so the js has some room to manipulate sizes.
60
return
[
61
'width'
=> (int)floor( $width * self::SCALE_FACTOR ),
62
'height'
=> (int)floor( $this->mHeights * self::SCALE_FACTOR ),
63
];
64
}
65
67
protected
function
getThumbDivWidth
( $thumbWidth ) {
68
// Require at least 60px wide, so caption is wide enough to work.
69
if
( $thumbWidth < 60 * self::SCALE_FACTOR ) {
70
$thumbWidth = 60 * self::SCALE_FACTOR;
71
}
72
73
return
$thumbWidth / self::SCALE_FACTOR + $this->
getThumbPadding
();
74
}
75
81
protected
function
getGBWidth
( $thumb ) {
82
$thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR;
83
84
return
$this->
getThumbDivWidth
( $thumbWidth ) + $this->
getGBPadding
();
85
}
86
88
protected
function
adjustImageParameters
( $thumb, &$imageParameters ) {
89
// Re-adjust back to normal size.
90
$imageParameters[
'override-width'
] = ceil( $thumb->getWidth() / self::SCALE_FACTOR );
91
$imageParameters[
'override-height'
] = ceil( $thumb->getHeight() / self::SCALE_FACTOR );
92
}
93
99
protected
function
getModules
() {
100
return
[
'mediawiki.page.gallery'
];
101
}
102
108
public
function
setPerRow
( $num ) {
109
}
110
}
111
113
class_alias( PackedImageGallery::class,
'PackedImageGallery'
);
MEDIATYPE_AUDIO
const MEDIATYPE_AUDIO
Definition
defines.php:19
MediaWiki\Gallery\ImageGalleryBase\$mWidths
int $mWidths
Definition
ImageGalleryBase.php:96
MediaWiki\Gallery\PackedImageGallery
Packed image gallery.
Definition
PackedImageGallery.php:16
MediaWiki\Gallery\PackedImageGallery\__construct
__construct( $mode='traditional', ?IContextSource $context=null)
Create a new image gallery object.You should not call this directly, but instead use ImageGalleryBase...
Definition
PackedImageGallery.php:18
MediaWiki\Gallery\PackedImageGallery\getThumbParams
getThumbParams( $img)
Definition
PackedImageGallery.php:50
MediaWiki\Gallery\PackedImageGallery\getModules
getModules()
Add javascript which auto-justifies the rows by manipulating the image sizes.
Definition
PackedImageGallery.php:99
MediaWiki\Gallery\PackedImageGallery\setPerRow
setPerRow( $num)
Do not support per-row on packed.
Definition
PackedImageGallery.php:108
MediaWiki\Gallery\PackedImageGallery\getThumbDivWidth
getThumbDivWidth( $thumbWidth)
Get the width of the inner div that contains the thumbnail in question.This is the div with the class...
Definition
PackedImageGallery.php:67
MediaWiki\Gallery\PackedImageGallery\adjustImageParameters
adjustImageParameters( $thumb, &$imageParameters)
Adjust the image parameters for a thumbnail.Used by a subclass to insert extra high resolution images...
Definition
PackedImageGallery.php:88
MediaWiki\Gallery\PackedImageGallery\getThumbPadding
getThumbPadding()
How much padding the thumb has between the image and the inner div that contains the border....
Definition
PackedImageGallery.php:37
MediaWiki\Gallery\PackedImageGallery\getVPad
getVPad( $boxHeight, $thumbHeight)
Get vertical padding for a thumbnail.Generally this is the total height minus how high the thumb is....
Definition
PackedImageGallery.php:32
MediaWiki\Gallery\PackedImageGallery\getGBWidth
getGBWidth( $thumb)
Definition
PackedImageGallery.php:81
MediaWiki\Gallery\PackedImageGallery\getGBPadding
getGBPadding()
GB stands for gallerybox (as in the element)int
Definition
PackedImageGallery.php:42
MediaWiki\Gallery\TraditionalImageGallery
Image gallery.
Definition
TraditionalImageGallery.php:27
MediaWiki\Context\IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition
IContextSource.php:57
includes
Gallery
PackedImageGallery.php
Generated on
for MediaWiki by
1.18.0