theme_picture's hook_theme declaration states that it has "attributes" variable:

    'picture' => array(
      'variables' => array(
        'style_name' => NULL,
        'path' => NULL,
        'uri' => NULL,
        'width' => NULL,
        'height' => NULL,
        'alt' => '',
        'title' => NULL,
        'attributes' => array(),
        'breakpoints' => array(),
      ),
    ),

However theme_picture_formatter doesn't pass any attributes set on the item to theme_picture:

  $responsive_image = array(
    '#theme' => 'picture',
    '#width' => isset($item['width']) ? $item['width'] : NULL,
    '#height' => isset($item['height']) ? $item['height'] : NULL,
    '#style_name' => $variables['image_style'],
    '#breakpoints' => $variables['breakpoints'],
    '#uri' => $item['uri'],
    '#alt' => isset($item['alt']) ? $item['alt'] : '',
  );

I propose to change the above to:

  $responsive_image = array(
    '#theme' => 'picture',
    '#width' => isset($item['width']) ? $item['width'] : NULL,
    '#height' => isset($item['height']) ? $item['height'] : NULL,
    '#style_name' => $variables['image_style'],
    '#breakpoints' => $variables['breakpoints'],
    '#uri' => $item['uri'],
    '#alt' => isset($item['alt']) ? $item['alt'] : '',
    '#attributes' => isset($item['attributes']) ? $item['attributes'] : NULL,
  );
CommentFileSizeAuthor
#1 picture-pass-attributes-2491293.patch527 bytesbaysaa

Comments

baysaa’s picture

Status: Active » Needs review
StatusFileSize
new527 bytes

Patch added.

attiks’s picture

Status: Needs review » Fixed

Thnaks

  • attiks committed b1e4a20 on 7.x-2.x authored by Baysaa
    Issue #2491293 by Baysaa: "attributes" not passed from...

Status: Fixed » Closed (fixed)

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