You are here

function elevatezoomplus_build in ElevateZoom Plus 7

Same name and namespace in other branches
  1. 8 elevatezoomplus.theme.inc \elevatezoomplus_build()

Build the main gallery image/ stage, if not using Slick asNavFor.

@todo remove first_item for _item post blazy:2.x.

1 call to elevatezoomplus_build()
template_preprocess_elevatezoomplus in ./elevatezoomplus.theme.inc
Prepares variables for theme_elevatezoomplus().

File

./elevatezoomplus.theme.inc, line 64
Hooks and preprocess functions for the Blazy module.

Code

function elevatezoomplus_build(array $settings = []) {
  $uri = isset($settings['_uri']) ? $settings['_uri'] : (isset($settings['first_uri']) ? $settings['first_uri'] : '');
  $item = isset($settings['first_item']) ? $settings['first_item'] : new \stdClass();
  $item = isset($settings['_item']) ? $settings['_item'] : $item;
  $url = empty($settings['box_style']) ? file_create_url($uri) : image_style_url($settings['box_style'], $uri);
  $style = empty($settings['thumbnail_style']) ? '' : $settings['thumbnail_style'];
  $param = [
    'image_style' => $style,
    'lazy' => 'blazy',
    'uri' => $uri,
  ];
  $id = Blazy::getHtmlId('elevatezoomplus');
  $zoom = [
    'data-zoom-image' => $url,
  ];
  $attrs = [
    'class' => [
      'elevatezoomplus elevatezoomplus--stage',
    ],
    'id' => $id,
  ] + $zoom;
  $build = [
    'item' => $item,
    'settings' => $param,
    'item_attributes' => $attrs,
  ];
  $stage = blazy()
    ->getBlazy($build);
  $stage['#attached'] = blazy()
    ->attach($param + $settings);
  $attrs = [
    'class' => [
      'elevatezoomplus-stage blazy',
    ],
    'data-blazy' => '',
  ];
  return Blazy::container($stage, $attrs);
}