You are here

public function SlickManager::attachSkin in Slick Carousel 8

Same name and namespace in other branches
  1. 8.2 src/SlickManager.php \Drupal\slick\SlickManager::attachSkin()
  2. 7.3 src/SlickManager.php \Drupal\slick\SlickManager::attachSkin()

Provides skins only if required.

1 call to SlickManager::attachSkin()
SlickManager::attach in src/SlickManager.php

File

src/SlickManager.php, line 173

Class

SlickManager
Implements BlazyManagerInterface, SlickManagerInterface.

Namespace

Drupal\slick

Code

public function attachSkin(array &$load, $attach = []) {
  if ($attach['slick_css']) {
    $load['library'][] = 'slick/slick.css';
  }
  if ($attach['module_css']) {
    $load['library'][] = 'slick/slick.theme';
  }
  if (!empty($attach['thumbnail_effect'])) {
    $load['library'][] = 'slick/slick.thumbnail.' . $attach['thumbnail_effect'];
  }
  if (!empty($attach['down_arrow'])) {
    $load['library'][] = 'slick/slick.arrow.down';
  }
  foreach (self::getConstantSkins() as $group) {
    $skin = $group == 'main' ? $attach['skin'] : (isset($attach['skin_' . $group]) ? $attach['skin_' . $group] : '');
    if (!empty($skin)) {
      $skins = $this
        ->getSkinsByGroup($group);
      $provider = isset($skins[$skin]['provider']) ? $skins[$skin]['provider'] : 'slick';
      $load['library'][] = 'slick/' . $provider . '.' . $group . '.' . $skin;
    }
  }
}