function hook_juicebox_gallery_alter in Juicebox HTML5 Responsive Image Galleries 7.2
Same name and namespace in other branches
- 8.3 juicebox.api.php \hook_juicebox_gallery_alter()
- 8.2 juicebox.api.php \hook_juicebox_gallery_alter()
Allow modules to alter the Juicebox gallery object used to build gallery embed code and XML before rendering.
Parameters
object $juicebox: A Juicebox gallery object that contains the gallery which is going to be rendered. This object can be further manipulated using any methods from JuiceboxGalleryDrupalInterface (which includes JuiceboxGalleryInterface).
mixed $data: The raw Drupal data that was used to build this gallery. Provided for context.
1 invocation of hook_juicebox_gallery_alter()
- JuiceboxGalleryDrupal::runCommonBuild in includes/
JuiceboxGalleryDrupal.inc - Common post-build tasks that should take place whenever a gallery of any type/source is built.
File
- ./
juicebox.api.php, line 22 - Hooks provided by the Juicebox module.
Code
function hook_juicebox_gallery_alter($juicebox, $data) {
// See if this is a gallery sourced from a view.
$id_args = $juicebox
->getIdArgs();
if ($id_args[0] == 'viewsstyle') {
$view = $data;
// Assume we have a view called "galleries" and a page called "page_1" that
// structures galleries based on a taxonomy term contextual filter. We want
// the juicebox "galleryDescription" option to be the term description, but
// because this term description is dynamic (based on contextual filter) we
// can't statically define it in the view's Juicebox settings. This hook
// let's us do the job dynamically.
if ($view->name == 'galleries' && $view->current_display == 'page_1') {
if (!empty($view->args)) {
$term = taxonomy_term_load($view->args[0]);
if (!empty($term->description)) {
// Add the description to the gallery.
$juicebox
->addOption('gallerydescription', strip_tags($term->description));
}
}
}
}
}