contao/test — Issue #2268: BE Image resize bug in AddImageToTemplate()
Author: importer
Created: 2011-11-29 09:23:12+00:00
State: open
Labels: backend, Defect

How to generate:
* Upload an image file with a normal photo ratio, e.g. 640x480
* Place a Text Element in an Article and attach the image
* make the Image size 350x90 -- creating a slim image strip with the width larger than the BE Max Width (so that part of the routine is triggered when in the BE)
* Save the CE, and then you will notice that the image is NOT resized to a strip of 300x77

The bug occurs in Controller LINE 2652 in method addImageToTemplate(), because when in BE mode and imageMaxWidth is triggered, then the resize is done on the original image's size ratio, instead of the CE's image desired size ratio.

The replacement coding would be something like this:

```
$ratio = $size[1] / $size[0]; // to use the desired size, instead of original size
$size[0] = $intMaxWidth;
$size[1] = floor($intMaxWidth * $ratio);

```

--- _Originally created by thyon on July 8th, 2010, at 04:39pm (ID 2268)_