X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fgallery%2FTraditionalImageGallery.php;h=f00e260e7ba0f8a5fa6b625a440b963e987946ec;hb=1cfa5d284bc2caf72ff404c78de1524e35c923a9;hp=0934f6aa09d95aae9fa61a20d7a9d17641f0a3f6;hpb=3de7e73bd0f0ddf5d7c38fd46edfae96d1a64e40;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/gallery/TraditionalImageGallery.php b/includes/gallery/TraditionalImageGallery.php index 0934f6aa09..f00e260e7b 100644 --- a/includes/gallery/TraditionalImageGallery.php +++ b/includes/gallery/TraditionalImageGallery.php @@ -43,15 +43,16 @@ class TraditionalImageGallery extends ImageGalleryBase { } $attribs = Sanitizer::mergeAttributes( - array( 'class' => 'gallery mw-gallery-' . $this->mMode ), $this->mAttribs ); + [ 'class' => 'gallery mw-gallery-' . $this->mMode ], $this->mAttribs ); $modules = $this->getModules(); - $modules[] = 'mediawiki.page.gallery.styles'; if ( $this->mParser ) { $this->mParser->getOutput()->addModules( $modules ); + $this->mParser->getOutput()->addModuleStyles( 'mediawiki.page.gallery.styles' ); } else { $this->getOutput()->addModules( $modules ); + $this->getOutput()->addModuleStyles( 'mediawiki.page.gallery.styles' ); } $output = Xml::openElement( 'ul', $attribs ); if ( $this->mCaption ) { @@ -72,9 +73,9 @@ class TraditionalImageGallery extends ImageGalleryBase { # Get the file... if ( $this->mParser instanceof Parser ) { # Give extensions a chance to select the file revision for us - $options = array(); + $options = []; Hooks::run( 'BeforeParserFetchFileAndTitle', - array( $this->mParser, $nt, &$options, &$descQuery ) ); + [ $this->mParser, $nt, &$options, &$descQuery ] ); # Fetch and register the file (file title may be different via hooks) list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $options ); } else { @@ -110,48 +111,51 @@ class TraditionalImageGallery extends ImageGalleryBase { htmlspecialchars( $nt->getText() ) ) . ''; - } elseif ( !( $thumb = $img->transform( $transformOptions ) ) ) { - # Error generating thumbnail. - $thumbhtml = "\n\t\t\t" . '
' - . htmlspecialchars( $img->getLastError() ) . '
'; } else { - /** @var MediaTransformOutput $thumb */ - $vpad = $this->getVPad( $this->mHeights, $thumb->getHeight() ); - - $imageParameters = array( - 'desc-link' => true, - 'desc-query' => $descQuery, - 'alt' => $alt, - 'custom-url-link' => $link - ); - - // In the absence of both alt text and caption, fall back on - // providing screen readers with the filename as alt text - if ( $alt == '' && $text == '' ) { - $imageParameters['alt'] = $nt->getText(); - } - - $this->adjustImageParameters( $thumb, $imageParameters ); - - Linker::processResponsiveImages( $img, $thumb, $transformOptions ); - - # Set both fixed width and min-height. - $thumbhtml = "\n\t\t\t" - . '
' - # Auto-margin centering for block-level elements. Needed - # now that we have video handlers since they may emit block- - # level elements as opposed to simple tags. ref - # http://css-discuss.incutio.com/?page=CenteringBlockElement - . '
' - . $thumb->toHtml( $imageParameters ) . '
'; - - // Call parser transform hook - /** @var MediaHandler $handler */ - $handler = $img->getHandler(); - if ( $this->mParser && $handler ) { - $handler->parserTransformHook( $this->mParser, $img ); + $thumb = $img->transform( $transformOptions ); + if ( !$thumb ) { + # Error generating thumbnail. + $thumbhtml = "\n\t\t\t" . '
' + . htmlspecialchars( $img->getLastError() ) . '
'; + } else { + /** @var MediaTransformOutput $thumb */ + $vpad = $this->getVPad( $this->mHeights, $thumb->getHeight() ); + + $imageParameters = [ + 'desc-link' => true, + 'desc-query' => $descQuery, + 'alt' => $alt, + 'custom-url-link' => $link + ]; + + // In the absence of both alt text and caption, fall back on + // providing screen readers with the filename as alt text + if ( $alt == '' && $text == '' ) { + $imageParameters['alt'] = $nt->getText(); + } + + $this->adjustImageParameters( $thumb, $imageParameters ); + + Linker::processResponsiveImages( $img, $thumb, $transformOptions ); + + # Set both fixed width and min-height. + $thumbhtml = "\n\t\t\t" + . '
' + # Auto-margin centering for block-level elements. Needed + # now that we have video handlers since they may emit block- + # level elements as opposed to simple tags. ref + # http://css-discuss.incutio.com/?page=CenteringBlockElement + . '
' + . $thumb->toHtml( $imageParameters ) . '
'; + + // Call parser transform hook + /** @var MediaHandler $handler */ + $handler = $img->getHandler(); + if ( $this->mParser && $handler ) { + $handler->parserTransformHook( $this->mParser, $img ); + } } } @@ -273,10 +277,10 @@ class TraditionalImageGallery extends ImageGalleryBase { * @return array */ protected function getThumbParams( $img ) { - return array( + return [ 'width' => $this->mWidths, 'height' => $this->mHeights - ); + ]; } /** @@ -312,7 +316,7 @@ class TraditionalImageGallery extends ImageGalleryBase { * @return array Modules to include */ protected function getModules() { - return array(); + return []; } /**