When using a predefined image size (https://github.com/contao/contao/pull/537), the teaser images of the ModuleNewsList will not be resized accordingly. Instead, only the original image will be shown.
The problem is this condition:
None of the conditions will be true, since the size array will look like this:
[
0 => "",
1 => "",
2 => "_foobar",
]
With the new predefined image sizes, none of the parameters will be numeric.
This problem exists in the following classes, as far as I can see:
ModuleNewsModuleEventListModuleEventReaderI am not sure what the correct fix is. May be add a fourth condition?
if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2]) || strpos($size[2], '_') === 0)
Are these checks needed at all actually? Doesn't the image factory handle all cases by itself anyway?
This affects Contao 4.8 and 4.9.
Are these checks needed at all actually?
I think so, yes. $arrArticle['size'] should only get overwritten if $this->imgSize is a “real” size.
For backwards compatibility sizes like [0, 0, 'proportional'] need to be handled the same way as if they are not set at all.
So how do we fix the issue?
I am not sure what the correct fix is. May be add a fourth condition?
As discussed on Mumble, yes.
($size[2][0] ?? null) === '_' should be the most performant way for the check, see https://3v4l.org/77aKk
Most helpful comment
I think so, yes.
$arrArticle['size']should only get overwritten if$this->imgSizeis a “real” size.For backwards compatibility sizes like
[0, 0, 'proportional']need to be handled the same way as if they are not set at all.