Drupal - Use lightbox with Views (Rel attribute) - in output link

kilrizzy picture kilrizzy · May 10, 2010 · Viewed 9.6k times · Source

In Drupal I have two image fields, one to act as a thumbnail and the other the image that will open when the thumbnail is clicked. The only way I could find to link the two was to use the option for "Output this field as a link" and link to the image field.

This works, so when I click the thumbnail it opens the larger image however I would like to use lightbox2 for this task but in the "Output this field as a link" options there is no way to set the "rel" attribute.

Is there a way to either set the rel attribute or invoke the lightbox by setting a class?

Answer

ax. picture ax. · May 13, 2010

you only need a single cck imagefield to get thumbnail plus full image in lightbox: Lightbox2 - How to use with CCK Imagefield and Imagecache.

UPDATE: use the "Lightbox Trigger" Views field of the Lightbox2 development version. step by step:

  • add both your thumbnail and your image field to your view
  • mark both of them "Exclude from display". don't check "Output this field as a link" anywhere.
  • add a "Lightbox trigger" field after both of your image fields
  • configure the "Lightbox trigger" field:
    • for "Trigger field", select your thumbnail field
    • for "Popup", select the Replacement pattern (scroll further down in the view field edit form for all possible replacement pattern) of your image field. for example, in my case, this is [field_image_fid].

now, your view should show your thumbnail image and, clicking on it, should open your full image in a lightbox frame. at least that's what's happening here :)