You are here

function slick_page_attachments in Slick Carousel 8.2

Implements hook_page_attachments().

File

./slick.module, line 99
Slick carousel integration, the last carousel you'll ever need.

Code

function slick_page_attachments(array &$attachments) {
  $sitewide = slick()
    ->configLoad('sitewide', 'slick.settings');
  if (!empty($sitewide) && $sitewide > 0 && !\Drupal::service('router.admin_context')
    ->isAdminRoute()) {
    $slicks = slick()
      ->attach([
      '_unload' => $sitewide == 2 || $sitewide == 3,
      '_vanilla' => $sitewide == 2,
    ]);
    $attachments['#attached'] = empty($attachments['#attached']) ? $slicks : NestedArray::mergeDeep($slicks, $attachments['#attached']);
  }
}