Closed LeoniePhiline closed 1 year ago
Thank you for your PR! I agree that this is unwanted behavior, however I don't think that sizes="123"
is valid HTML. I think that it is required to specify a CSS unit there, for example sizes="123px"
.
https://html.spec.whatwg.org/multipage/images.html#sizes-attributes
Holy cow, how haven’t I noticed that? I just checked the file history, and this bug has been in the template for several years. Mind blowing.
The
sizes
argument is defined inImageViewHelper
andMediaViewHelper
as such:However, arguments provided through fluid templates are not automatically coerced into the defined type (here:
'string'
).This means that e.g. in
MediaViewHelper::renderImageSrcset
, this call might fail ifsizes
is not a string:Here is a real life partial where exactly this happens:
As
width
is a variable assigned by evaluating a math expression, it is of typeint
when it is fed into theMediaViewHelper
.This hard-fails with:
I propose coercing types manually, since TYPO3 (11) does not do that, despite arguments being declared with types:
Here, only
$this->arguments['sizes']
is force-cast tostring
(and, unchanged,placeholderSize
toint
).This might be recommendable for all incoming
$this->arguments
where receiving functions have strict argument type restrictions.See also https://github.com/sitegeist/sms-responsive-images/commit/f13d0cbd3080d65eebf8250de9b0d6d8473fbecf