Thank you for a great module!

Problem/Motivation

Error message when enabling insert_responsive_image:
Warning: array_merge(): Expected parameter 2 to be an array, null given in insert_responsive_image_insert_variables() (line 73 of .../modules/insert/modules/insert_responsive_image/insert_responsive_image.module).

It seems there are no variables collected from the call to template_preprocess_responsive_image().

Steps to reproduce

With devel enabled, and error handlers enabled: enable the module, make sure responsive styles exist, enable the insert in a block entity, make sure reponsive styles are made selectable, edit a custom block with the insert enabled, use a responsive style.

Proposed resolution

To remove the error message (but not fixing the issue), it is possible to rewrite lines 72-73 to:
isset($vars['attributes']) ? $vars['attributes'] : [],
isset($responsiveImageVars['attributes']) ? $responsiveImageVars['attributes'] : []

but it is likely some more processing is needed on the responsiveImageVars. Dumping the variable with dpm does not seem to reveal any "attributes" to merge.

CommentFileSizeAuthor
#3 insert-3176560-responsive_image.patch736 bytesSnater
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jfranzen created an issue. See original summary.

jfranzen’s picture

The way you define the responsive image styles seem to affect this.
With the default styles Narrow and Wide, the src-set attribute is found and set.
However, creating a responsive image style using separate breakpoints and image styles at these breakpoints, the src-set is not defined.

Snater’s picture

Status: Active » Needs review
FileSize
736 bytes

Thanks for trying out the insert_responsive_image module. Getting things work Insert with the Responsive Image module really depends on feedback, especially since I am not a Drupal power user. :)

Your suggestion seems reasonable. So if that is what's necessary to fix the issue, then let's merge in that change. I attached a patch set that would apply the code as suggested by you.

Neslee Canil Pinto’s picture

Version: 8.x-2.0-beta2 » 8.x-2.x-dev
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.