This should be very simple for a good Drupaller:
I'm using Lightbox2 on a new site. I've set Lightbox as the handler for Image node settings, via the Lightbox2 "Automatic image handling" settings page (settings/lightbox2/automatic). One click on the "Attached image" of a content node summons a familiar large-size Lightbox image. No problem.
I also have Views displaying a random image node in a block. I'd like a click on that block's image to 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 .
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?
Question answer:
Yes, I was fundamentally mistaken in my understanding of what I need to do to have a Views-generated image trigger Lightbox.
Re-reading the Lightbox2 settings more carefully, I see the key phrase "Choose how URLs for [such-and-such] images will be automatically handled" repeated for many settings.
Ah, that may be what I was skipping over. Perhaps Lightbox2 is looking for URLs, not certain classes, attached to the images. Going back to the Views settings for my random image block, I found the desired setting under the Fields section, where I had specified "Image: Image" as the field to appear in the View. The settings for that field include the option "Link this field to its node". I had originally left this unchecked, as I don't want clicks on images taking users to a page built on the image node. But, as I soon confirmed, that's not a worry; with a link URL in place on the images, Lightbox2 intercepts those links and performs its magic, opening a big floating image on the same page. Boom!
Now, what about inline images in my general nodes, the ones embedded helter-skelter amidst node text via my WYSIWYG text editor (TinyMCE and IMCE, if you must know)? I was getting no Lightbox2 click love there either. "Ah", I brilliantly surmised after enough tequila, "Perhaps you want a URL there as well, Lightbox2?" Ever so gently, I adorned my inline image with – for lack of a better idea – a link to its actual location in the file system (files/image.jpg or whatever).
"Now you understand me", breathed Lightbox2, and graced my inline with that old popup hoodoo. She/he/it and I have been like this (crosses fingers) ever since.
I don't know that the above is the way to best work Lightbox2 into a site, but as a quick solution to what I was looking for, it did the trick for me.
I have heard and read stories such as this one before, and their common denominator is Drupal...
excellent tip - can highly recommend the module - installed and working perfectly in drupal 7
This book seems very interesting as I am currently starting a project to build a community site...
Thank you very much !
Thank you very much !