MediaWiki
REL1_39
PackedImageGallery.php
Go to the documentation of this file.
1
<?php
23
class
PackedImageGallery
extends
TraditionalImageGallery
{
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
}
ImageGalleryBase\$mWidths
int $mWidths
Definition
ImageGalleryBase.php:100
PackedImageGallery
Definition
PackedImageGallery.php:23
PackedImageGallery\getGBWidth
getGBWidth( $thumb)
Definition
PackedImageGallery.php:83
PackedImageGallery\getThumbPadding
getThumbPadding()
How much padding the thumb has between the image and the inner div that contains the border.
Definition
PackedImageGallery.php:41
PackedImageGallery\getVPad
getVPad( $boxHeight, $thumbHeight)
Get vertical padding for a thumbnail.
Definition
PackedImageGallery.php:37
PackedImageGallery\__construct
__construct( $mode='traditional', IContextSource $context=null)
Create a new image gallery object.
Definition
PackedImageGallery.php:24
PackedImageGallery\getModules
getModules()
Add javascript which auto-justifies the rows by manipulating the image sizes.
Definition
PackedImageGallery.php:100
PackedImageGallery\getThumbDivWidth
getThumbDivWidth( $thumbWidth)
Get the width of the inner div that contains the thumbnail in question.
Definition
PackedImageGallery.php:69
PackedImageGallery\getGBPadding
getGBPadding()
Definition
PackedImageGallery.php:45
PackedImageGallery\setPerRow
setPerRow( $num)
Do not support per-row on packed.
Definition
PackedImageGallery.php:109
PackedImageGallery\getThumbParams
getThumbParams( $img)
Definition
PackedImageGallery.php:53
PackedImageGallery\adjustImageParameters
adjustImageParameters( $thumb, &$imageParameters)
Adjust the image parameters for a thumbnail.
Definition
PackedImageGallery.php:89
TraditionalImageGallery
Definition
TraditionalImageGallery.php:29
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition
IContextSource.php:58
MEDIATYPE_AUDIO
const MEDIATYPE_AUDIO
Definition
defines.php:32
includes
gallery
PackedImageGallery.php
Generated on Mon Dec 23 2024 06:23:18 for MediaWiki by
1.10.0