contao/test — Issue #1582: Image scaling in FileTree
Author: importer
Created: 2011-11-29 08:11:12+00:00
State: open
Labels: backend, Defect

In system/modules/backend/FileTree.php renderFiletree() line ~397 getImage is used to get the thumb image to render with the tree. Uploading images bigger than 3000px is not blocked, and if someone does so, the FileTree UI is not usable anymore, since the thumbnail has not been scaled because the original image was bigger than 3000 pixels. Here is the solution I implemented:

```
if ($GLOBALS['TL_CONFIG']['thumbnails'])
{
$_height = ($objFile->height < 70) ? $objFile->height : 70;
$_width = (($objFile->width * $_height / $objFile->height) > 400) ? 90 : '';
/*
* kuu, 7. feb 2010
* images bigger than 3000 are not scaled (gdlib memory limit) by getImage().
* but since upload was allowed, we need to adjust its size to maintain a good layout.
** **/
$thumbfilename = $this->getImage($currentEncoded, $_width, $_height);
$imgDimStyle = "";
if($thumbfilename == $currentFile){
$imgDimStyle = sprintf("height:%spx;width:%spx;", $height, ($objFile->width * ($_height / $objFile->height)));
}

$thumbnail = '
';
}
```

--- _Originally created by bubblez on February 18th, 2010, at 05:34pm (ID 1582)_