Undefined array key "height" and "width" when using "Responsive Background Image" formatter

Created on 19 July 2023, 12 months ago
Updated 14 November 2023, 8 months ago

Problem/Motivation

The "Responsive Background Image" formatter is throwing a warning with Drupal 10.1+.

The following is a snippet of the error (in French) is the Drupal log:
Warning : Undefined array key "width" dans template_preprocess_responsive_image() (/var/www/html/web/core/modules/responsive_image/responsive_image.module ligne 209)
#0 /var/www/html/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/w...', 209)
#1 /var/www/html/web/core/modules/responsive_image/responsive_image.module(209): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/w...', 209)
#2 /var/www/html/web/modules/contrib/bg_image_formatter/modules/responsive_bg_image_formatter/src/Plugin/Field/FieldFormatter/ResponsiveBgImageFormatter.php(105): template_preprocess_responsive_image(Array)
#3 /var/www/html/web/core/lib/Drupal/Core/Field/FormatterBase.php(89): Drupal\responsive_bg_image_formatter\Plugin\Field\FieldFormatter\ResponsiveBgImageFormatter->viewElements(Object(Drupal\file\Plugin\Field\FieldType\FileFieldItemList), 'fr')...

This issue may relate to the following core issue:
https://www.drupal.org/project/drupal/issues/3359421 🐛 (Re-)Add width / height also on fallback image Fixed
** The patch found in the issue above could not be applied to D10.1+ so I was not able to test it out.

Steps to reproduce

Use the "Responsive Background Image" formatter on a media display. Make use of the media display in the front-end of a site and navigate to the page.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.16

Component

Code

Created by

🇨🇦Canada joelseguin Ontario, Canada

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

Comments & Activities

Production build 0.69.0 2024