Problem/Motivation
#3359421: (Re-)Add width / height also on fallback image and #3192234: Apply width and height attributes to allow responsive image tag use loading="lazy" added width/height attributes on fallback images. If the responsive_image variables are missing either of these keys they are stripped at the very start of the preprocessor
if (isset($variables['width']) && empty($variables['width'])) {
unset($variables['width']);
unset($variables['height']);
}
elseif (isset($variables['height']) && empty($variables['height'])) {
unset($variables['width']);
unset($variables['height']);
}
Steps to reproduce
Render something with
$build = [
'#theme' => 'responsive_image_formatter',
'#responsive_image_style_id' => 'some_id',
'#uri' => 'blah',
];
And do not add width or height variables.
Proposed resolution
NULL checks on the fallback.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3375721
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
acbramley commentedComment #4
recrit commentedThe fix in the MR worked for me. I set to "Needs work" since this needs tests for the missing width and height keys.
Comment #5
hchonovStatic patch for the MR:
Comment #7
majid.ali commentedAdding static patch for MR based on latest https://git.drupalcode.org/project/drupal/-/merge_requests/4416
MR works so changing status to needs review.
Comment #8
majid.ali commentedComment #9
smustgrave commentedMR appears to be red and probably needs test coverage right? Maybe small enough not
Comment #10
acbramley commentedMR just needed a rebase. I would think test coverage would be a lot of effort for something so trivial but I'm not sure.
Comment #11
recrit commentedstatic patch of latest MR 4416