Undefined index sources in lazy_preprocess_responsive_image()

Created on 15 December 2020, almost 4 years ago
Updated 29 November 2023, 10 months ago

Problem/Motivation

I noticed this error:

Notice: Undefined index: sources in lazy_preprocess_responsive_image() (line 287 of modules/contrib/lazy/lazy.module).
lazy_preprocess_responsive_image(Array, 'responsive_image', Array) (Line: 287)

Occuring on certain pages. I went through the debugger and found that some images sent to this hook do not have a sources key at all, and thus no data. This was causing errors inside this hook which assumes this key will always be present. I noticed that certain responsive image styles with no breakpoints set will cause the sources key to be empty.

Steps to reproduce

Have an empty sources key for an element passed to this hook. Occurs when no breakpoints are set for a responsive image style.

Proposed resolution

To stop this issue we should skip images if the sources key does not exist.

Remaining tasks

none

User interface changes

none

API changes

none

Data model changes

none

πŸ› Bug report
Status

Postponed: needs info

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Bits8myBytes

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024