I was getting a fatal error caused by bootstrap_preprocess_picture since the code was trying to add an array element to what turns out to be a string sometimes. The $variables['attributes']['class'] is sometimes a string, sometimes empty, and sometimes an array, so the patch adds checks for each case.

Comments

ShaunDychko created an issue. See original summary.

shaundychko’s picture

shaundychko’s picture

Status: Active » Needs review
markhalliwell’s picture

Title: Fix fatal error when adding the responsive image class in bootstrap_preprocess_picture » Template variables are not preprocessed
Project: Bootstrap » Picture
Version: 7.x-3.10 » 7.x-2.x-dev
Status: Needs review » Needs work
Related issues: +#2269653: [bootstrap][policy][7.x-3.x] CSS Classes (Fatal error: [] operator not supported for strings)

This is a bug with the picture module then, because it's the one that introduces the picture theme hook. It's their responsibility for setting up the variables array appropriately.

For example:the majority of what is happening in theme_picture(), should be moved to a new template_preprocess_picture() function.

geoffreyr’s picture

StatusFileSize
new608 bytes

Here's a patch for Picture module that forces class attributes to an array.

geoffreyr’s picture

Status: Needs work » Needs review

attiks’s picture

Status: Needs review » Fixed

Committed

  • attiks committed a945790 on 7.x-2.x authored by geoffreyr
    Issue #2835769 by ShaunDychko, geoffreyr, markcarver: Template variables...

Status: Fixed » Closed (fixed)

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