39 if ( $this->mPerRow > 0 ) {
40 $maxwidth = $this->mPerRow * ( $this->mWidths + $this->
getAllPadding() );
41 $oldStyle = $this->mAttribs[
'style'] ??
'';
42 # _width is ignored by any sane browser. IE6 doesn't know max-width
43 # so it uses _width instead
44 $this->mAttribs[
'style'] =
"max-width: {$maxwidth}px;_width: {$maxwidth}px;" .
49 [
'class' =>
'gallery mw-gallery-' . $this->mMode ], $this->mAttribs );
53 if ( $this->mParser ) {
54 $this->mParser->getOutput()->addModules(
$modules );
55 $this->mParser->getOutput()->addModuleStyles(
'mediawiki.page.gallery.styles' );
58 $this->
getOutput()->addModuleStyles(
'mediawiki.page.gallery.styles' );
61 if ( $this->mCaption ) {
62 $output .=
"\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
65 if ( $this->mShowFilename ) {
69 foreach ( $this->mImages as $img ) {
70 $lb->addObj( $img[0] );
76 # Output each image...
77 foreach ( $this->mImages as $pair ) {
80 list( $nt, $text, $alt, $link ) = $pair;
83 if ( $nt->getNamespace() ===
NS_FILE ) {
85 if ( $this->mParser instanceof
Parser ) {
86 # Give extensions a chance to select the file revision for us
89 [ $this->mParser, $nt, &$options, &$descQuery ] );
90 # Fetch and register the file (file title may be different via hooks)
91 list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $options );
93 $img = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $nt );
101 $transformOptions = $params + $pair[4];
106 # We're dealing with a non-image, spit out the name and be done with it.
107 $thumbhtml =
"\n\t\t\t" .
'<div class="thumb" style="height: '
109 . htmlspecialchars( $nt->getText() ) .
'</div>';
111 if ( $this->mParser instanceof
Parser ) {
112 $this->mParser->addTrackingCategory(
'broken-file-category' );
114 } elseif ( $this->mHideBadImages && MediaWikiServices::getInstance()->getBadFileLookup()
115 ->isBadFile( $nt->getDBkey(), $this->getContextTitle() )
117 # The image is blacklisted, just show it as a text link.
118 $thumbhtml =
"\n\t\t\t" .
'<div class="thumb" style="height: ' .
122 htmlspecialchars( $nt->getText() )
126 $thumb = $img->transform( $transformOptions );
128 # Error generating thumbnail.
129 $thumbhtml =
"\n\t\t\t" .
'<div class="thumb" style="height: '
131 . htmlspecialchars( $img->getLastError() ) .
'</div>';
134 $vpad = $this->
getVPad( $this->mHeights, $thumb->getHeight() );
138 'desc-query' => $descQuery,
140 'custom-url-link' => $link
145 if ( $alt ==
'' && $text ==
'' ) {
146 $imageParameters[
'alt'] = $nt->getText();
153 # Set both fixed width and min-height.
154 $thumbhtml =
"\n\t\t\t"
155 .
'<div class="thumb" style="width: '
157 # Auto-margin centering for block-level elements. Needed
158 # now that we have video handlers since they may emit block-
159 # level elements as opposed to simple <img> tags. ref
160 # http://css-discuss.incutio.com/?page=CenteringBlockElement
161 .
'<div style="margin:' . $vpad .
'px auto;">'
162 . $thumb->toHtml( $imageParameters ) .
'</div></div>';
166 $handler = $img->getHandler();
167 if ( $this->mParser && $handler ) {
168 $handler->parserTransformHook( $this->mParser, $img );
181 if ( $this->mShowDimensions ) {
182 $meta[] = $img->getDimensionsString();
184 if ( $this->mShowBytes ) {
185 $meta[] = htmlspecialchars(
$lang->formatSize( $img->getSize() ) );
187 } elseif ( $this->mShowDimensions || $this->mShowBytes ) {
188 $meta[] = $this->
msg(
'filemissing' )->escaped();
190 $meta =
$lang->semicolonList( $meta );
195 $textlink = $this->mShowFilename ?
199 $galleryText = $textlink . $text . $meta;
202 $gbWidth = $this->
getGBWidth( $thumb ) .
'px';
206 # Weird double wrapping (the extra div inside the li) needed due to FF2 bug
207 # Can be safely removed if FF2 falls completely out of existence
208 $output .=
"\n\t\t" .
'<li class="gallerybox" style="width: '
210 .
'<div style="width: ' . $gbWidth .
'">'
213 .
"\n\t\t</div></li>";
215 $output .=
"\n</ul>";
235 'class' =>
'galleryfilename' .
236 ( $this->getCaptionLength() ===
true ?
' galleryfilename-truncate' :
'' )
250 # ATTENTION: The newline after <div class="gallerytext"> is needed to
251 # accommodate htmltidy which in version 4.8.6 generated crackpot html in
252 # its absence, see: https://phabricator.wikimedia.org/T3765
255 return "\n\t\t\t" .
'<div class="gallerytext">' .
"\n"
319 protected function getVPad( $boxHeight, $thumbHeight ) {