function jcarousel_page_attachments in jCarousel 8.5
Same name and namespace in other branches
- 8.4 jcarousel.module \jcarousel_page_attachments()
Implements hook_page_attachments().
File
- ./
jcarousel.module, line 737 - Provides integration with 3rd party modules and the jCarousel library.
Code
function jcarousel_page_attachments(&$page) {
if (!\Drupal::config('jcarousel.settings')
->get('global_load')) {
return;
}
$options = [
'skin' => 'default',
'scroll' => 1,
'vertical' => 0,
'navigation' => 'after',
];
// Add the jCarousel library and any global settings.
$page['#attached']['library'][] = 'jcarousel/jcarousel';
$page['#attached']['library'][] = 'jcarousel/jcarousel.swipe';
$page['#attached']['library'][] = 'jcarousel/drupal.jcarousel';
// Allow other modules to modify these settings.
\Drupal::moduleHandler()
->alter('jcarousel_options', $options, $class_name);
$skins = \Drupal::service('jcarousel.skins.manager')
->getDefinitions();
foreach ($skins as $id => $skin) {
$variables['#attached']['library'][] = 'jcarousel/skin.' . $id;
}
}