Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/298020

Change subject: Truncate gallery caption filenames with CSS
......................................................................

Truncate gallery caption filenames with CSS

Bug: T139766
Change-Id: Iba7efb8f89e132b8eb39f3c9ba76d2b1a9181b2f
---
M includes/DefaultSettings.php
M includes/gallery/TraditionalImageGallery.php
M resources/src/mediawiki/page/gallery.css
3 files changed, 18 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/20/298020/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index fccc20a..f68a9a2 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -1444,7 +1444,8 @@
        '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 when included 
in caption (with "showfilename")
+       'captionLength' => null, // Length to truncate filename to when 
included in caption (with "showfilename").
+                                // A value of 'null' will use CSS truncation.
        'showBytes' => true, // Show the filesize in bytes in categories
        'mode' => 'traditional',
 ];
diff --git a/includes/gallery/TraditionalImageGallery.php 
b/includes/gallery/TraditionalImageGallery.php
index 2fb2281..754d601 100644
--- a/includes/gallery/TraditionalImageGallery.php
+++ b/includes/gallery/TraditionalImageGallery.php
@@ -185,12 +185,16 @@
                                $fileSize = '';
                        }
 
+
                        $textlink = $this->mShowFilename ?
                                // Preloaded into LinkCache above
                                Linker::linkKnown(
                                        $nt,
-                                       htmlspecialchars( $lang->truncate( 
$nt->getText(), $this->mCaptionLength ) )
-                               ) . "<br />\n" :
+                                       htmlspecialchars(
+                                               $this->mCaptionLength ? 
$lang->truncate( $nt->getText(), $this->mCaptionLength ) : $nt->getText()
+                                       ),
+                                       [ 'class' => 'galleryfilename' . ( 
!$this->mCaptionLength ? ' galleryfilename-truncate' : '' ) ]
+                               ) . "\n" :
                                '';
 
                        $galleryText = $textlink . $text . $fileSize;
diff --git a/resources/src/mediawiki/page/gallery.css 
b/resources/src/mediawiki/page/gallery.css
index 4d43e6a..d765144 100644
--- a/resources/src/mediawiki/page/gallery.css
+++ b/resources/src/mediawiki/page/gallery.css
@@ -45,6 +45,16 @@
        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;

-- 
To view, visit https://gerrit.wikimedia.org/r/298020
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba7efb8f89e132b8eb39f3c9ba76d2b1a9181b2f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to