From: Ed Sanders Date: Fri, 8 Jul 2016 16:41:51 +0000 (+0100) Subject: Truncate gallery caption filenames with CSS X-Git-Tag: 1.31.0-rc.0~6351^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=486027d7d5bec36728aa17130d32fe98cf58947f;p=lhc%2Fweb%2Fwiklou.git Truncate gallery caption filenames with CSS Bug: T139766 Change-Id: Iba7efb8f89e132b8eb39f3c9ba76d2b1a9181b2f --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index f6611acad0..50884458f5 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1444,7 +1444,10 @@ $wgGalleryOptions = [ 'imagesPerRow' => 0, // Default number of images per-row in the gallery. 0 -> Adapt to screensize 'imageWidth' => 120, // Width of the cells containing images in galleries (in "px") 'imageHeight' => 120, // Height of the cells containing images in galleries (in "px") - 'captionLength' => 25, // Length to truncate filename to in caption when using "showfilename" + 'captionLength' => true, // Deprecated @since 1.28 + // Length to truncate filename to in caption when using "showfilename". + // A value of 'true' will truncate the filename to one line using CSS + // and will be the behaviour after deprecation. 'showBytes' => true, // Show the filesize in bytes in categories 'mode' => 'traditional', ]; diff --git a/includes/gallery/TraditionalImageGallery.php b/includes/gallery/TraditionalImageGallery.php index 2fb22815d5..f6527b820e 100644 --- a/includes/gallery/TraditionalImageGallery.php +++ b/includes/gallery/TraditionalImageGallery.php @@ -189,8 +189,16 @@ class TraditionalImageGallery extends ImageGalleryBase { // Preloaded into LinkCache above Linker::linkKnown( $nt, - htmlspecialchars( $lang->truncate( $nt->getText(), $this->mCaptionLength ) ) - ) . "
\n" : + htmlspecialchars( + $this->mCaptionLength !== true ? + $lang->truncate( $nt->getText(), $this->mCaptionLength ) : + $nt->getText() + ), + [ + 'class' => 'galleryfilename' . + ( $this->mCaptionLength === true ? ' galleryfilename-truncate' : '' ) + ] + ) . "\n" : ''; $galleryText = $textlink . $text . $fileSize; diff --git a/resources/src/mediawiki/page/gallery.css b/resources/src/mediawiki/page/gallery.css index 4d43e6af83..d765144294 100644 --- a/resources/src/mediawiki/page/gallery.css +++ b/resources/src/mediawiki/page/gallery.css @@ -45,6 +45,16 @@ div.gallerytext { word-wrap: break-word; } +.galleryfilename { + display: block; +} + +.galleryfilename-truncate { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + /* new gallery stuff */ ul.mw-gallery-nolines li.gallerybox div.thumb { background-color: transparent; diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 2e059d7423..aa5ed05967 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -18816,7 +18816,7 @@ File:Foobar.jpg
  • Nonexistent.jpg
    @@ -18824,14 +18824,14 @@ caption
  • Nonexistent.jpg
  • @@ -18839,7 +18839,7 @@ some caption Main Page
  • Foobar.jpg