public function ImageZoomGalleryFormatter::viewElements in Image Zoom 8.3
Builds a renderable array for a field value.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.
string $langcode: The language that should be used to render the field.
Return value
array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.
Overrides ImageZoomFormatter::viewElements
File
- src/
Plugin/ Field/ FieldFormatter/ ImageZoomGalleryFormatter.php, line 67
Class
- ImageZoomGalleryFormatter
- Image Zoom gallery field formatter for Image fields.
Namespace
Drupal\imagezoom\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
$profile = ImageZoomOptions::load($this
->getSetting('imagezoom_options'));
$options = $profile
->getOptions();
$settings = [
'zoomType' => $options['zoom_type'],
'gallery' => 'imagezoom-thumb-wrapper',
];
if ($options['disable']) {
$settings['responsive'] = TRUE;
$settings['respond'] = [
[
'range' => '0 - ' . $options['disable_width'],
'enabled' => FALSE,
],
];
}
$this->moduleHandler
->alter('imagezoom_settings', $settings);
$element[] = [
'#theme' => 'imagezoom_gallery',
'#items' => $items,
'#display_style' => $options['display_style'],
'#zoom_style' => $options['zoom_style'],
'#thumb_style' => $options['thumb_style'],
'#settings' => $settings,
];
$element['#attached'] = [
'library' => [
'imagezoom/elevatezoom',
],
'drupalSettings' => [
'imagezoom' => $settings,
],
];
return $element;
}