function template_preprocess_dxpr_gridstack_gridstack_formatter in DXPR GridStack 8
Same name and namespace in other branches
- 1.0.x theme.inc \template_preprocess_dxpr_gridstack_gridstack_formatter()
Prepares variables for gridstack formatter templates.
Default template: sooperthemes-gridstack-gridstack-formatter.html.twig.
Parameters
array $vars: An associative array containing:
- item: An ImageItem object.
- item_attributes: An optional associative array of html attributes to be placed in the img tag.
- image_style: An optional image style.
- url: An optional \Drupal\Core\Url object.
File
- ./
theme.inc, line 24 - Preprocess functions for DXPR GridStack module.
Code
function template_preprocess_dxpr_gridstack_gridstack_formatter(&$vars) {
/** @var \Drupal\file\FileInterface $entity */
$entity = $vars['item']->entity;
$image_uri = $entity && empty($vars['item']->uri) ? $entity
->getFileUri() : $vars['item']->uri;
$vars['image_url'] = $vars['image_style'] ? ImageStyle::load($vars['image_style'])
->buildUrl($image_uri) : file_create_url($image_uri);
}