You are here

function flexslider_libraries_info_alter in Flex Slider 8.2

Same name and namespace in other branches
  1. 7.2 flexslider.module \flexslider_libraries_info_alter()

Implements hook_libraries_info_alter().

@TODO: Remove this once 8.9 is the minimal core version and Libraries is no longer required.

File

./flexslider.module, line 47
A light-weight, customizable image gallery plugin for Drupal based on jQuery.

Code

function flexslider_libraries_info_alter(&$libraries) {
  $debug = \Drupal::config('flexslider.settings')
    ->get('flexslider_debug');
  if ($debug) {

    // Switch to the unminified version of the library.
    if (isset($libraries['flexslider'])) {
      $libraries['flexslider']['files']['js'] = [
        'jquery.flexslider.js',
      ];
    }
  }

  // Add support for jQuery Easing module.
  if (\Drupal::moduleHandler()
    ->moduleExists('jqeasing')) {
    $libraries['flexslider']['dependencies'][] = 'easing (>=1.3)';
  }

  // Remove the library css if privileged user disabled it.
  if (!\Drupal::config('flexslider.settings')
    ->get('flexslider_css')) {
    if (!empty($libraries['flexslider']['files']['css']) && ($key = array_search('flexslider.css', $libraries['flexslider']['files']['css']))) {
      unset($libraries['flexslider']['files']['css'][$key]);
    }
  }
}