Drupal + LightBox2 component = use body as title (caption) for lightbox
-
19-09-2019 - |
Question
I am using the LightBox2 component on my website to display the gallery images in a grouped lightbox. I add images to the website by using the Image
component and adding all the images to the Photos book. However, images can still be viewed separately on a page, if I so choose. The url would then look something like this: www.myurl.com/node/37
with body content (that I added in the Create Image process) displaying beneath the image.
I was wondering if I can get this body content of this new image node page to display as the title for the Lightbox when it opens, if a user clicks on an image in the gallery.
TIA
Solution
It seems impossible without hacking the Lightbox2 module. If you modify Image Gallery's view to include image's body field, you'll be able to hack lightbox2\js\auto_image_handling.js to take body as title.
OTHER TIPS
yes, write a function that prints the html you want to show, register the function with hook_menu, then call it. voila.
e.g.
function mymodule_menu() {
$items['lightboxhtml'] = array(
'page callback' => 'mymodule_html4lightbox',
'page arguments' => array(1),
...
}
function mymodule_html4lightbox($nid) {
$node = node_load($nid);
print $node->body;
exit;
}
in the that calls lightbox, call it with /lightboxhtml/$nid as the href.