#109899The f:image.srcset VH wrongly requires the srcset attribute (instead of defaulting to "1x"), the official HTML spec has it as optional (defaulting to "1x")
Description
See https://html.spec.whatwg.org/#srcset-attribute – zero or one
> Zero or one of the following:
> # A width descriptor, consisting of: ASCII whitespace, a valid non-negative integer giving a number greater than zero representing the width descriptor value, and a U+0077 LATIN SMALL LETTER W character.
> # A pixel density descriptor, consisting of: ASCII whitespace, a valid floating-point number giving a number greater than zero representing the pixel density descriptor value, and a U+0078 LATIN SMALL LETTER X character.
And Mozilla says explicitly this, https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/source#srcset
> If the descriptors are not specified, the default value used is 1x
However, the f:image.srcset ViewHelper has this:
$this->registerArgument(‘srcset’, ‘string’, ‘Comma-separated list of width descriptors (e. g. 200w) or pixel density descriptors (e. g. 2x).’, true);
So, the required flag set to true for the srcset argument. This is HTML-spec-violating.
Correct would be $required = false and $defaultValue = '1x'.
Of course, we could adjust hundreds of places by explcitly passing “1x” – but this is super-tedious and basically renders this VH useless (in the sense of comfort-gain). Much better would be if the VH behaves just fully compliant to the HTML-spec oob.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[BUGFIX] The f:image.srcset VH wrongly requires the srcset attribute (instead of defaulting to "1x"), the official HTML spec has it as optional (defaulting to "1x") Resolves: #109899 Releases: main