Undefined array key errors for responsive_image themeing without width or height

Created on 20 July 2023, 11 months ago
Updated 28 May 2024, 29 days ago

Problem/Motivation

πŸ› (Re-)Add width / height also on fallback image Fixed and πŸ“Œ Apply width and height attributes to allow responsive image tag use loading="lazy" Fixed 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.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Responsive imageΒ  β†’

Last updated 12 days ago

Created by

πŸ‡¦πŸ‡ΊAustralia acbramley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024