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
Comment #2
Bits8myBytes commentedHere is a patch for 3.6
Comment #3
Bits8myBytes commentedHere is a patch for current dev branch
Comment #4
osmanHey 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?
Comment #5
dieterholvoet commentedI 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.
Comment #6
missvengerberg commentedHi, I have the same problem in a project and the patches cannot be applied for v3.12 or dev, so created a new patch.