public static function BlazyViews::viewsPreRender in Blazy 8.2
Same name and namespace in other branches
- 8 src/BlazyViews.php \Drupal\blazy\BlazyViews::viewsPreRender()
Implements hook_views_pre_render().
1 call to BlazyViews::viewsPreRender()
- blazy_views_pre_render in ./
blazy.module - Implements hook_views_pre_render().
File
- src/
BlazyViews.php, line 15
Class
- BlazyViews
- Provides optional Views integration.
Namespace
Drupal\blazyCode
public static function viewsPreRender($view) {
// Load Blazy library once, not per field, if any Blazy Views field found.
if ($blazy = self::viewsField($view)) {
$plugin_id = $view
->getStyle()
->getPluginId();
$settings = $blazy
->mergedViewsSettings();
$load = $blazy
->blazyManager()
->attach($settings);
$view->element['#attached'] = empty($view->element['#attached']) ? $load : NestedArray::mergeDeep($view->element['#attached'], $load);
$grid = $plugin_id == 'blazy';
if ($options = $view
->getStyle()->options) {
$grid = empty($options['grid']) ? $grid : TRUE;
}
// Prevents dup [data-LIGHTBOX-gallery] if the Views style supports Grid.
if (!$grid) {
$view->element['#attributes'] = empty($view->element['#attributes']) ? [] : $view->element['#attributes'];
Blazy::containerAttributes($view->element['#attributes'], $settings);
}
}
}