public function JuiceboxFormatter::getLibrary in Juicebox HTML5 Responsive Image Galleries 8.2
Same name and namespace in other branches
- 8.3 src/JuiceboxFormatter.php \Drupal\juicebox\JuiceboxFormatter::getLibrary()
Get/detect the details of a Juicebox javascript library without loading it.
This is essentially a wrapper for libraries_detect() with some caching added. It also allows library info to be fetched independently from the currently loaded version if needed (e.g., to accomodate XML requests that don't come from this site).
Parameters
bool $force_local: Whether-or-not to force detection of the LOCALLY installed Juicebox library details. If FALSE Libraries API detection may be bypased if library version details can be detected through the URL.
bool $reset: Whether-or-not to bypass and reset any caching information.
Return value
array An associative array of the library information.
Overrides JuiceboxFormatterInterface::getLibrary
4 calls to JuiceboxFormatter::getLibrary()
- JuiceboxFormatter::confBaseForm in src/
JuiceboxFormatter.php - Get common elements for Juicebox configuration forms.
- JuiceboxFormatter::confBaseStylePresets in src/
JuiceboxFormatter.php - Get the image style preset options.
- JuiceboxFormatter::newGallery in src/
JuiceboxFormatter.php - Create and initialize a new Juicebox gallery object.
- JuiceboxFormatter::styleImage in src/
JuiceboxFormatter.php - Utility to style an individual file entity for use in a Juicebox gallery.
File
- src/
JuiceboxFormatter.php, line 138
Class
- JuiceboxFormatter
- Class to define a Drupal service with common formatter methods.
Namespace
Drupal\juiceboxCode
public function getLibrary($force_local = FALSE, $reset = FALSE) {
// We use our own static cache to lazy-load the lib. Libraries API detection
// has a static cache, but as we may be bypassing full local detection in
// certain situations, we can't always use it.
$library =& self::$library;
if (!$library || $reset) {
// See if we have been passed version details in the URL. If so we bypass
// local detection and build our own libraries array.
$query = \Drupal::request()->query
->all();
if (!empty($query['jb-version']) && !$force_local) {
juicebox_library_info($library);
$version_number = Html::escape($query['jb-version']);
if (!empty($query['jb-pro'])) {
$library['pro'] = TRUE;
$version = 'Pro';
}
else {
$version = 'Lite';
}
$library['version'] = $version . ' ' . $version_number;
juicebox_library_post_detect($library);
}
else {
$library = libraries_detect('juicebox');
}
}
return $library;
}