function flexslider_library_info_alter in Flex Slider 8.2
Implements hook_library_info_alter().
File
- ./
flexslider.module, line 74 - A light-weight, customizable image gallery plugin for Drupal based on jQuery.
Code
function flexslider_library_info_alter(&$libraries, $extension) {
if ($extension == 'flexslider' and isset($libraries['flexslider'])) {
// Remove the library and/or module css if privileged user disabled it.
if (!\Drupal::config('flexslider.settings')
->get('flexslider_css')) {
if (isset($libraries['flexslider']['css'])) {
unset($libraries['flexslider']['css']);
}
}
if (!\Drupal::config('flexslider.settings')
->get('flexslider_module_css')) {
if (isset($libraries['integration']['css'])) {
unset($libraries['integration']['css']);
}
}
$standard = '/libraries/flexslider';
// @TODO Remove this conditional once 8.9 is the minimum supported core
// version.
if (\Drupal::hasService('library.libraries_directory_file_finder')) {
/** @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder $library_file_finder */
$library_file_finder = \Drupal::service('library.libraries_directory_file_finder');
$library_path = '/' . $library_file_finder
->find('flexslider');
}
elseif (\Drupal::moduleHandler()
->moduleExists('libraries')) {
$library_path = '/' . libraries_get_path('flexslider');
// Set correct path to where the library was downloaded if not standard.
if ($library_path !== $standard) {
$libraries['flexslider']['js'][$library_path . '/jquery.flexslider-min.js'] = $libraries['flexslider']['js'][$standard . '/jquery.flexslider-min.js'];
unset($libraries['flexslider']['js'][$standard . '/jquery.flexslider-min.js']);
if (!empty($libraries['flexslider']['css'])) {
$libraries['flexslider']['css']['component'][$library_path . '/flexslider.css'] = $libraries['flexslider']['css']['component'][$standard . '/flexslider.css'];
unset($libraries['flexslider']['css']['component'][$standard . '/flexslider.css']);
}
}
}
else {
$library_path = $standard;
}
// Enable debug mode.
$debug = \Drupal::config('flexslider.settings')
->get('flexslider_debug');
if ($debug) {
// Add the unminified version.
$libraries['flexslider']['js'] = [
$library_path . '/jquery.flexslider.js' => [],
];
}
// Add support for jQuery Easing module.
if (\Drupal::moduleHandler()
->moduleExists('jqeasing')) {
// Using the jqeasing module.
$libraries['flexslider']['dependencies'][] = 'jqeasing.easing';
}
}
}