Show dimensions in TraditionalImageGallery
Bug: T121869 Change-Id: Ie2cb3f1594302f1726ae3d9d2d668c81b7e6b0f1
This commit is contained in:
parent
167f6f27ae
commit
ebb1680359
5 changed files with 34 additions and 9 deletions
|
|
@ -1455,6 +1455,8 @@ $wgGalleryOptions = [
|
|||
'captionLength' => true,
|
||||
// Show the filesize in bytes in categories
|
||||
'showBytes' => true,
|
||||
// Show the dimensions (width x height) in categories
|
||||
'showDimensions' => true,
|
||||
'mode' => 'traditional',
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ abstract class ImageGalleryBase extends ContextSource {
|
|||
*/
|
||||
protected $mShowBytes;
|
||||
|
||||
/**
|
||||
* @var bool Whether to show the dimensions in categories
|
||||
*/
|
||||
protected $mShowDimensions;
|
||||
|
||||
/**
|
||||
* @var bool Whether to show the filename. Default: true
|
||||
*/
|
||||
|
|
@ -136,6 +141,7 @@ abstract class ImageGalleryBase extends ContextSource {
|
|||
$galleryOptions = $this->getConfig()->get( 'GalleryOptions' );
|
||||
$this->mImages = [];
|
||||
$this->mShowBytes = $galleryOptions['showBytes'];
|
||||
$this->mShowDimensions = $galleryOptions['showDimensions'];
|
||||
$this->mShowFilename = true;
|
||||
$this->mParser = false;
|
||||
$this->mHideBadImages = false;
|
||||
|
|
@ -283,6 +289,16 @@ abstract class ImageGalleryBase extends ContextSource {
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -174,15 +174,20 @@ class TraditionalImageGallery extends ImageGalleryBase {
|
|||
// ":{$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 ?
|
||||
|
|
@ -201,7 +206,7 @@ class TraditionalImageGallery extends ImageGalleryBase {
|
|||
) . "\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
|
||||
|
|
|
|||
|
|
@ -4971,6 +4971,7 @@ class Parser {
|
|||
|
||||
$ig->setContextTitle( $this->mTitle );
|
||||
$ig->setShowBytes( false );
|
||||
$ig->setShowDimensions( false );
|
||||
$ig->setShowFilename( false );
|
||||
$ig->setParser( $this );
|
||||
$ig->setHideBadImages();
|
||||
|
|
|
|||
|
|
@ -821,6 +821,7 @@ class SpecialUpload extends SpecialPage {
|
|||
|
||||
$gallery = ImageGalleryBase::factory( false, $this->getContext() );
|
||||
$gallery->setShowBytes( false );
|
||||
$gallery->setShowDimensions( false );
|
||||
foreach ( $dupes as $file ) {
|
||||
$gallery->add( $file->getTitle() );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue