36 if ( $this->mPerRow > 0 ) {
37 $maxwidth = $this->mPerRow * ( $this->mWidths + $this->
getAllPadding() );
38 $oldStyle = $this->mAttribs[
'style'] ??
'';
39 # _width is ignored by any sane browser. IE6 doesn't know max-width
40 # so it uses _width instead
41 $this->mAttribs[
'style'] =
"max-width: {$maxwidth}px;_width: {$maxwidth}px;" .
45 $attribs = Sanitizer::mergeAttributes(
46 [
'class' =>
'gallery mw-gallery-' . $this->mMode ], $this->mAttribs );
50 if ( $this->mParser ) {
51 $this->mParser->getOutput()->addModules(
$modules );
52 $this->mParser->getOutput()->addModuleStyles(
'mediawiki.page.gallery.styles' );
55 $this->
getOutput()->addModuleStyles(
'mediawiki.page.gallery.styles' );
58 if ( $this->mCaption ) {
59 $output .=
"\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
62 if ( $this->mShowFilename ) {
66 foreach ( $this->mImages as $img ) {
67 $lb->addObj( $img[0] );
73 # Output each image...
74 foreach ( $this->mImages as $pair ) {
80 if ( $nt->getNamespace() ===
NS_FILE ) {
82 if ( $this->mParser instanceof
Parser ) {
83 # Give extensions a chance to select the file revision for us
85 Hooks::run(
'BeforeParserFetchFileAndTitle',
86 [ $this->mParser, $nt, &
$options, &$descQuery ] );
87 # Fetch and register the file (file title may be different via hooks)
88 list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt,
$options );
98 $transformOptions =
$params + $pair[4];
103 # We're dealing with a non-image, spit out the name and be done with it.
104 $thumbhtml =
"\n\t\t\t" .
'<div class="thumb" style="height: '
108 if ( $this->mParser instanceof
Parser ) {
109 $this->mParser->addTrackingCategory(
'broken-file-category' );
111 }
elseif ( $this->mHideBadImages
112 &&
wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() )
114 # The image is blacklisted, just show it as a text link.
115 $thumbhtml =
"\n\t\t\t" .
'<div class="thumb" style="height: ' .
123 $thumb = $img->transform( $transformOptions );
125 # Error generating thumbnail.
126 $thumbhtml =
"\n\t\t\t" .
'<div class="thumb" style="height: '
131 $vpad = $this->
getVPad( $this->mHeights, $thumb->getHeight() );
137 'custom-url-link' =>
$link
142 if ( $alt ==
'' && $text ==
'' ) {
143 $imageParameters[
'alt'] = $nt->getText();
150 # Set both fixed width and min-height.
151 $thumbhtml =
"\n\t\t\t"
152 .
'<div class="thumb" style="width: '
154 # Auto-margin centering for block-level elements. Needed
155 # now that we have video handlers since they may emit block-
156 # level elements as opposed to simple <img> tags. ref
158 .
'<div style="margin:' . $vpad .
'px auto;">'
159 . $thumb->toHtml( $imageParameters ) .
'</div></div>';
165 $handler->parserTransformHook( $this->mParser, $img );
177 if ( $this->mShowDimensions ) {
178 $meta[] = $img->getDimensionsString();
180 if ( $this->mShowBytes ) {
183 }
elseif ( $this->mShowDimensions || $this->mShowBytes ) {
184 $meta[] = $this->
msg(
'filemissing' )->escaped();
186 $meta =
$lang->semicolonList( $meta );
191 $textlink = $this->mShowFilename ?
195 $galleryText = $textlink . $text .
$meta;
198 $gbWidth = $this->
getGBWidth( $thumb ) .
'px';
202 # Weird double wrapping (the extra div inside the li) needed due to FF2 bug
203 # Can be safely removed if FF2 falls completely out of existence
204 $output .=
"\n\t\t" .
'<li class="gallerybox" style="width: '
206 .
'<div style="width: ' . $gbWidth .
'">'
209 .
"\n\t\t</div></li>";
231 'class' =>
'galleryfilename' .
246 # ATTENTION: The newline after <div class="gallerytext"> is needed to
247 # accommodate htmltidy which in version 4.8.6 generated crackpot html in
248 # its absence, see: https:
251 return "\n\t\t\t" .
'<div class="gallerytext">' .
"\n"
315 protected function getVPad( $boxHeight, $thumbHeight ) {
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfFindFile( $title, $options=[])
Find a file.
wfIsBadImage( $name, $contextTitle=false, $blacklist=null)
Determine if an image exists on the 'bad image list'.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
bool int $mCaptionLength
Length to truncate filename to in caption when using "showfilename".
getRenderLang()
Determines the correct language to be used for this image gallery.
Internationalisation code.
truncateForVisual( $string, $length, $ellipsis='...', $adjustLength=true)
Truncate a string to a specified number of characters, appending an optional string (e....
Class representing a list of titles The execute() method checks them all for existence and adds them ...
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
static processResponsiveImages( $file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Represents a title within MediaWiki.
getThumbPadding()
How much padding the thumb has between the image and the inner div that contains the border.
getCaptionLength()
Length (in characters) to truncate filename to in caption when using "showfilename" (if int).
getVPad( $boxHeight, $thumbHeight)
Get vertical padding for a thumbnail.
getThumbParams( $img)
Get the transform parameters for a thumbnail.
toHTML()
Return a HTML representation of the image gallery.
getGBWidth( $thumb)
Computed width of gallerybox .
getModules()
Get a list of modules to include in the page.
getGBBorders()
Get how much extra space the borders around the image takes up.
getCaptionHtml(Title $nt, Language $lang)
wrapGalleryText( $galleryText, $thumb)
Add the wrapper html around the thumb's caption.
adjustImageParameters( $thumb, &$imageParameters)
Adjust the image parameters for a thumbnail.
getGBWidthOverwrite( $thumb)
Allows overwriting the computed width of the gallerybox with a string, like '100'.
getAllPadding()
Get total padding.
getThumbDivWidth( $thumbWidth)
Get the width of the inner div that contains the thumbnail in question.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
usually copyright or history_copyright This message must be in HTML not wikitext & $link
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
if(!isset( $args[0])) $lang