'captionLength' => true,
// Show the filesize in bytes in categories
'showBytes' => true,
+ // Show the dimensions (width x height) in categories
+ 'showDimensions' => true,
'mode' => 'traditional',
];
*/
protected $mShowBytes;
+ /**
+ * @var bool Whether to show the dimensions in categories
+ */
+ protected $mShowDimensions;
+
/**
* @var bool Whether to show the filename. Default: true
*/
$galleryOptions = $this->getConfig()->get( 'GalleryOptions' );
$this->mImages = [];
$this->mShowBytes = $galleryOptions['showBytes'];
+ $this->mShowDimensions = $galleryOptions['showDimensions'];
$this->mShowFilename = true;
$this->mParser = false;
$this->mHideBadImages = false;
return empty( $this->mImages );
}
+ /**
+ * Enable/Disable showing of the dimensions of an image in the gallery.
+ * Enabled by default.
+ *
+ * @param bool $f Set to false to disable
+ */
+ function setShowDimensions( $f ) {
+ $this->mShowDimensions = (bool)$f;
+ }
+
/**
* Enable/Disable showing of the file size of an image in the gallery.
* Enabled by default.
// ":{$ut}" );
// $ul = Linker::link( $linkTarget, $ut );
- if ( $this->mShowBytes ) {
- if ( $img ) {
- $fileSize = htmlspecialchars( $lang->formatSize( $img->getSize() ) );
- } else {
- $fileSize = $this->msg( 'filemissing' )->escaped();
+ $meta = [];
+ if ( $img ) {
+ if ( $this->mShowDimensions ) {
+ $meta[] = $img->getDimensionsString();
}
- $fileSize = "$fileSize<br />\n";
- } else {
- $fileSize = '';
+ if ( $this->mShowBytes ) {
+ $meta[] = htmlspecialchars( $lang->formatSize( $img->getSize() ) );
+ }
+ } elseif ( $this->mShowDimensions || $this->mShowBytes ) {
+ $meta[] = $this->msg( 'filemissing' )->escaped();
+ }
+ $meta = $lang->semicolonList( $meta );
+ if ( $meta ) {
+ $meta .= "<br />\n";
}
$textlink = $this->mShowFilename ?
) . "\n" :
'';
- $galleryText = $textlink . $text . $fileSize;
+ $galleryText = $textlink . $text . $meta;
$galleryText = $this->wrapGalleryText( $galleryText, $thumb );
# Weird double wrapping (the extra div inside the li) needed due to FF2 bug
$ig->setContextTitle( $this->mTitle );
$ig->setShowBytes( false );
+ $ig->setShowDimensions( false );
$ig->setShowFilename( false );
$ig->setParser( $this );
$ig->setHideBadImages();
$gallery = ImageGalleryBase::factory( false, $this->getContext() );
$gallery->setShowBytes( false );
+ $gallery->setShowDimensions( false );
foreach ( $dupes as $file ) {
$gallery->add( $file->getTitle() );
}