throw new SystemException("Unknown thumbnail size '".$size."'");
}
+ if (!$this->{$size.'ThumbnailType'}) {
+ return $this->getLink();
+ }
+
return LinkHandler::getInstance()->getLink('Media', [
'forceFrontend' => true,
'object' => $this,
]);
}
+ /**
+ * Returns the width of the thumbnail file with the given size.
+ *
+ * @param string $size
+ * @return integer
+ * @throws SystemException
+ */
+ public function getThumbnailWidth($size) {
+ if (!isset(self::$thumbnailSizes[$size])) {
+ throw new SystemException("Unknown thumbnail size '".$size."'");
+ }
+
+ if ($this->{$size.'ThumbnailType'}) {
+ return $this->{$size.'ThumbnailWidth'};
+ }
+
+ return $this->width;
+ }
+
+ /**
+ * Returns the height of the thumbnail file with the given size.
+ *
+ * @param string $size
+ * @return integer
+ * @throws SystemException
+ */
+ public function getThumbnailHeight($size) {
+ if (!isset(self::$thumbnailSizes[$size])) {
+ throw new SystemException("Unknown thumbnail size '".$size."'");
+ }
+
+ if ($this->{$size.'ThumbnailType'}) {
+ return $this->{$size.'ThumbnailHeight'};
+ }
+
+ return $this->height;
+ }
+
/**
* @inheritDoc
*/
throw new SystemException("Unknown thumbnail size '".$size."'");
}
- return '<img src="'.$this->getThumbnailLink($size).'" alt="'.StringUtil::encodeHTML($this->altText).'" '.($this->title ? 'title="'.StringUtil::encodeHTML($this->title).'" ' : '').'/>';
+ return '<img src="'.$this->getThumbnailLink($size).'" alt="'.StringUtil::encodeHTML($this->altText).'" '.($this->title ? 'title="'.StringUtil::encodeHTML($this->title).'" ' : '').'style="width: ' . $this->getThumbnailWidth($size) . 'px; height: ' . $this->getThumbnailHeight($size) . 'px;">';
}
/**