Resolve TODO in ViewableMedia::getElementTag()
authorMatthias Schmidt <gravatronics@live.com>
Sun, 3 Jan 2016 08:50:27 +0000 (09:50 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 3 Jan 2016 08:50:27 +0000 (09:50 +0100)
wcfsetup/install/files/lib/data/media/ViewableMedia.class.php

index a0e9750701435d4e789fd0ba8457f6bcb857d845..5e82edccb56993451259e0356ff2ce022a01d4e2 100644 (file)
@@ -42,9 +42,11 @@ class ViewableMedia extends DatabaseObjectDecorator {
         * @return      string
         */
        public function getElementTag($size) {
-               // todo: validate $size
                if ($this->isImage && $this->tinyThumbnailType) {
-                       return '<img src="'.$this->getThumbnailLink('tiny').'" alt="'.StringUtil::encodeHTML($this->altText).'" style="width: '.$size.'px; height: '.$size.'px;" />';
+                       $tinyThumbnail = Media::getThumbnailSizes()['tiny'];
+                       if ($size <= $tinyThumbnail['width'] && $size <= $tinyThumbnail['height']) {
+                               return '<img src="' . $this->getThumbnailLink('tiny') . '" alt="' . StringUtil::encodeHTML($this->altText) . '" style="width: ' . $size . 'px; height: ' . $size . 'px;" />';
+                       }
                }
                
                return '<span class="icon icon'.$size.' '.FileUtil::getIconClassByMimeType($this->fileType).'"></span>';