You are here

function juicebox_library_post_detect in Juicebox HTML5 Responsive Image Galleries 8.2

Same name and namespace in other branches
  1. 7.2 juicebox.module \juicebox_library_post_detect()

Libraries API Post-Detect Callback.

Add detailed variables to a Juicebox library array after the version info can be detected.

See also

juicebox_libraries_info()

1 call to juicebox_library_post_detect()
JuiceboxFormatter::getLibrary in src/JuiceboxFormatter.php
Get/detect the details of a Juicebox javascript library without loading it.
1 string reference to 'juicebox_library_post_detect'
juicebox_libraries_info in ./juicebox.module
Implements hook_libraries_info().

File

./juicebox.module, line 130
Module file for Juicebox.

Code

function juicebox_library_post_detect(&$library) {
  $pro = FALSE;
  $disallowed_conf = [];
  if (!empty($library['version'])) {

    // Check if this is a Pro version.
    if (stripos($library['version'], "Pro") !== FALSE) {
      $pro = TRUE;
    }

    // Get numeric part of the version statement.
    $version_number = 0;
    $matches = [];
    preg_match("/[0-9\\.]+[^\\.]\$/u", $library['version'], $matches);
    if (!empty($matches[0])) {
      $version_number = $matches[0];
    }

    // Some options are not available as LITE options < v1.3.
    if (!$pro && version_compare($version_number, '1.3', '<')) {
      $disallowed_conf = array_merge($disallowed_conf, [
        'jlib_textColor',
        'jlib_thumbFrameColor',
        'jlib_useFullscreenExpand',
        'jlib_useThumbDots',
      ]);
    }

    // Multisize features are only available in PRO >= v1.4.
    if (!$pro || version_compare($version_number, '1.4', '<')) {
      $disallowed_conf = array_merge($disallowed_conf, [
        'juicebox_multisize_image_style',
      ]);
    }

    // Set the correct languageList string.
    if (version_compare($version_number, '1.4.0', '>=')) {
      $library['base_languagelist'] .= '|Images';
    }
    if ($pro) {
      $library['base_languagelist'] .= '|Next Image|Previous Image|Play Audio|Pause Audio|Show Information|Hide Information|Start AutoPlay|Stop AutoPlay|AutoPlay ON|AutoPlay OFF|Go Back|Buy this Image|Share on Facebook|Share on Twitter|Share on Google+|Share on Pinterest|Share on Tumblr|of';
      if (version_compare($version_number, '1.5.0', '>=')) {
        $library['base_languagelist'] .= '|Send Email|Download';
      }
    }
  }
  $library['pro'] = $pro;
  $library['disallowed_conf'] = $disallowed_conf;
}