function template_preprocess_jcarousel in jCarousel 8.5
Same name and namespace in other branches
- 8.4 jcarousel.module \template_preprocess_jcarousel()
Preprocess function for jcarousel.html.twig.
File
- ./
jcarousel.module, line 559 - Provides integration with 3rd party modules and the jCarousel library.
Code
function template_preprocess_jcarousel(&$variables) {
// Set default options.
$variables['options'] += [
'skin' => 'default',
'scroll' => 1,
'vertical' => 0,
'navigation' => 'after',
'visible' => 4,
];
$options = $variables['options'];
// Add the jCarousel library and any global settings.
$variables['#attached']['library'][] = 'jcarousel/jcarousel';
$variables['#attached']['library'][] = 'jcarousel/jcarousel.swipe';
$variables['#attached']['library'][] = 'jcarousel/drupal.jcarousel';
// Allow other modules to modify these settings.
\Drupal::moduleHandler()
->alter('jcarousel_options', $options, $class_name);
if (!empty($options['skin'])) {
$variables['#attached']['library'][] = 'jcarousel/skin.' . $options['skin'];
}
$variables['options'] = $options;
unset($variables['attributes']);
$variables += _jcarousel_generate_attributes($variables['items'], $variables['options']);
}