public function JuiceboxFormatter::getLibrary in Juicebox HTML5 Responsive Image Galleries 8.3
Same name and namespace in other branches
- 8.2 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 196
Class
- JuiceboxFormatter
- Class to define a Drupal service with common formatter methods.
Namespace
Drupal\juiceboxCode
public function getLibrary($force_local = FALSE, $reset = FALSE) {
// We "default" to sites/all/libraries and that will override
// anything in /libraries. Rationale is that sites/all/libraries
// was the original location for these files theoretically,
// we could check the versions of both and pick the one
// with the highest version not sure the juice(box) is worth the squeeze.
if (file_exists(DRUPAL_ROOT . '/' . 'sites/all/libraries/juicebox/juicebox.js')) {
$librarypath = '/sites/all/libraries/juicebox/juicebox.js';
}
elseif (file_exists(DRUPAL_ROOT . '/' . 'libraries/juicebox/juicebox.js')) {
$librarypath = '/libraries/juicebox/juicebox.js';
}
if (isset($librarypath)) {
juicebox_build_library_array($librarypath, $library);
}
else {
$notification_top = $this
->t('The Juicebox Javascript library does not appear to be installed. Please download and install the most recent version of the Juicebox library.');
$this->messenger
->addError($notification_top);
}
return $library;
}