*/
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;
/**
* Set the caption (as plain text)
*
- * @param string $caption Caption
+ * @param string $caption
*/
function setCaption( $caption ) {
$this->mCaption = htmlspecialchars( $caption );
/**
* Set the caption (as HTML)
*
- * @param string $caption Caption
+ * @param string $caption
*/
public function setCaptionHtml( $caption ) {
$this->mCaption = $caption;
/**
* Set how wide each image will be, in pixels.
*
- * @param int $num Integer > 0; invalid numbers will be ignored
+ * @param string $num Number. Unit other than 'px is invalid. Invalid numbers
+ * and those below 0 are ignored.
*/
public function setWidths( $num ) {
- if ( $num > 0 ) {
- $this->mWidths = (int)$num;
+ $parsed = Parser::parseWidthParam( $num, false );
+ if ( isset( $parsed['width'] ) && $parsed['width'] > 0 ) {
+ $this->mWidths = $parsed['width'];
}
}
/**
* Set how high each image will be, in pixels.
*
- * @param int $num Integer > 0; invalid numbers will be ignored
+ * @param string $num Number. Unit other than 'px is invalid. Invalid numbers
+ * and those below 0 are ignored.
*/
public function setHeights( $num ) {
- if ( $num > 0 ) {
- $this->mHeights = (int)$num;
+ $parsed = Parser::parseWidthParam( $num, false );
+ if ( isset( $parsed['width'] ) && $parsed['width'] > 0 ) {
+ $this->mHeights = $parsed['width'];
}
}
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.