Hi,

I am using bootstrap theme and found out that it is not possible to insert image using ckeditor media browser and to the same token insert data-picture-mapping.
I get white screen with php error: Fatal error: [] operator not supported for strings in /var/www/testshop.eotazky/html/sites/all/themes/bootstrap/templates/picture/picture.vars.php on line 19

With other themes everything works ok. The problem might be: CSS class passed as a string instead of array?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

loparr created an issue. See original summary.

ice70’s picture

Hi loparr,

No sure if the $variables['attributes']['class'] is expected to be a string or array elsewhere.
I also found it gave out warnings if the $variables['attributes']['class'] was missing,

updated /sites/all/themes/bootstrap/templates/picture/picture.vars.php
as follow and it then worked as expected:

function bootstrap_preprocess_picture(&$variables) {
  // Add responsiveness, if necessary.
  if ($shape = bootstrap_setting('image_responsive')) {
    if (empty($variables['attributes']['class'])) {
      $variables['attributes']['class'] = array();
    }
    if (!is_array($variables['attributes']['class'])) {
      $variables['attributes']['class'] .= ' img-responsive';
    }
    else {
      $variables['attributes']['class'][] = 'img-responsive';
    }
  }
}
kyletaylored’s picture

Project: Picture » Bootstrap

This actually looks like a Bootstrap issue instead of a Picture issue (the theme needs to support the module).

We need to initialize an array if it hasn't been already.

kyletaylored’s picture

Title: bootstrap combine media tokens with data-picture-mapping » Classes array not initialized (Picture module template)
Version: 7.x-2.x-dev » 7.x-3.x-dev
Status: Active » Needs review
FileSize
757 bytes

Rolled the last suggestion into a patch.

markhalliwell’s picture

Category: Bug report » Support request
Status: Needs review » Closed (won't fix)
Related issues: +#2269653: [bootstrap][policy][7.x-3.x] CSS Classes (Fatal error: [] operator not supported for strings)

This is not an issue with this project.