This should be very simple for a good Drupaller:
I'm using Lightbox 2 on a site. By setting Lightbox as the handler for Image node settings, via the settings page (settings/lightbox2/automatic), one click on an image summons a familiar large-size Lightbox image. No problem.
In a block, I have Views displaying a random image from the site. I'd like a click on that block's image to also trigger Lightbox, but nothing happens.
From perusing bits and pieces on drupal.org, my understanding is that I need to
1) Give the image(s) displayed by Views a unique class; and
2) Specify that class under the "Custom class images" option at settings/lightbox2/automatic .
Does that sound correct? If so:
The HTML currently generated by the site includes the following, for the random image Views block:
<div class="content"><div class="view view-Random-image view-id-Random_image view-display-id-block_1 view-dom-id-1">
<div class="view-content">
<div class="views-row views-row-1 views-row-odd views-row-first">
<div class="views-field-image-image">
<span class="field-content"><img src="[path to image]image.JPG" class="image image-preview " width="280" height="210" /></span>
</div>That offers plenty of classes to play with. I don't know which should be usable as the trigger for Lightbox, but I've tried them all in the Lightbox "Custom class images" setting – image image preview , field-content, views-field-image-image, everything appearing above – and nothing triggers Lightbox in my Views block.
Am I fundamentally mistaken in my understanding of what I need to do to have a Views-generated image trigger Lightbox? Sorry, my Drupal image-manipulation kung fu remains weak. I welcome any needed whacks upside the head.
Comments
Lightbox2 and Views
I'll answer my own question here:
I don't know whether there's an answer involving classes, but re-reading the settings more carefully, I realized that Lightbox2 appears to be searching for a *URL* as its trigger. Perhaps it only works on images with links?
Whatever the full story on Lighbox2 workings, I added "Link to node" to my images in the Views settings, and voila, that got Lightbox2 working on the block images. In addition, by putting links on inline images, Lightbox2 does its thing for them too. So, that settles my question for now.
More detail at
http://www.drupalace.com/questions/how-to-make-lightbox2-work-for-views-...