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

Comments

Bits8myBytes created an issue. See original summary.

Bits8myBytes’s picture

StatusFileSize
new706 bytes

Here is a patch for 3.6

Bits8myBytes’s picture

StatusFileSize
new629 bytes

Here is a patch for current dev branch

osman’s picture

Status: Active » Postponed (maintainer needs more info)

Hey Ben, if you still experience this issue on current version, could you detail your responsive image settings?

What markup Drupal generates for your responsive images?
PHP version?

dieterholvoet’s picture

I just encountered the same issue. The cause was me creating a module with the same name as an existing theme which defined breakpoints, causing the breakpoints of that theme to not be loaded anymore and the responsive image styles to be broken. Removing the new module fixed the issue.

missvengerberg’s picture

StatusFileSize
new1.17 KB

Hi, I have the same problem in a project and the patches cannot be applied for v3.12 or dev, so created a new patch.