You are here

public static function BlazyViews::preprocessViewsView in Blazy 8.2

Implements hook_preprocess_views_view().

1 call to BlazyViews::preprocessViewsView()
blazy_preprocess_views_view in ./blazy.module
Implements hook_preprocess_views_view().

File

src/BlazyViews.php, line 51

Class

BlazyViews
Provides optional Views integration.

Namespace

Drupal\blazy

Code

public static function preprocessViewsView(array &$variables, $lightboxes) {
  preg_match('~blazy--(.*?)-gallery~', $variables['css_class'], $matches);
  $lightbox = $matches[1] ? str_replace('-', '_', $matches[1]) : FALSE;

  // Given blazy--photoswipe-gallery, adds the [data-photoswipe-gallery], etc.
  if ($lightbox && in_array($lightbox, $lightboxes)) {
    $settings['namespace'] = 'blazy';
    $settings['media_switch'] = $matches[1];
    $variables['attributes'] = empty($variables['attributes']) ? [] : $variables['attributes'];
    Blazy::containerAttributes($variables['attributes'], $settings);
  }
}