Hey everyone,

Seem to be having a problem with Lightbox2 and Drupal 7, the captions won't show in the lightbox. Anyone having the same problem, or have a suggestion for fixing?

Best Regards,


Sameo’s picture

I have the same problem.

stephen.punwasi’s picture

Hey Sameo,

Tried a fresh install, once again didn't work. Didn't have the time to figure out how to fix it, so I ended up using Yoxview instead. Similar features, not as customizable but if you're in a client-crunch you might want to check it out.

Keep us posted if you figure out what's not working, looks like the handler isn't passing on the information to be rendered.

blw0010’s picture

Same problem. I can not get the captions to show from the alt or title attribute.

tammo’s picture

Same for me, subscribing

yukare’s picture

Component: Miscellaneous » Code
Category: support » bug
Priority: Major » Normal

I had this working in the past, so some change i did broke it, will work on this.

yukare’s picture

It works if you put it inside the rel tag, like rel="lightbox[][my caption here]" but is not working with title="my caption".

El Bandito’s picture


I'm having this problem too. I am using Views to display images in a sidebar and have selected a lightbox formatter. It looks like the rel=" attribute is corrupted. Here is what my browser sees output for one of the images :

<div class="views-field views-field-field-photos">
<div class="field-content">
<div class="item-list">
<li class="first">
<a class="lightbox-processed" title="The large beer garden" rel="lightbox[field_photos][The large beer garden<p><a href="http://www.theturnpikeinn.info/sites/default/files/sidebar-photos/garden.jpg"></a></p>]" href="http://www.theturnpikeinn.info/sites/default/files/sidebar-photos/garden.jpg">
<img width="180" height="135" title="The large beer garden" alt="The large beer garden" src="http://www.theturnpikeinn.info/sites/default/files/styles/sidebar_photo/public/sidebar-photos/garden.jpg">

Any thoughts appreciated.


El B

yukare’s picture

Status: Active » Fixed

This is related to #971754. I just commited a fix for it, and will commit it too in drupal 6 later. See http://drupalcode.org/project/lightbox2.git/commit/000ef72

I made a very simple testing site at http://jaguaribe.net23.net/ to show this working, just wait for the next dev release.

El Bandito’s picture

Status: Fixed » Active

Thanks yukare. I downloaded the dev version but I must be to early as it didn't have the change. So I applied the tiny change by hand and it worked fine.

Thanks for your efforts and swift response.

yukare’s picture

Status: Active » Fixed

Since the solution worked for you, I will set again this issue as fixed.

cruze72’s picture

Sorry, any ideas how this needs to be manually configured in views. Have a slideshow gallery and it still doesn't show the captions. Have used the dev version from 30th Dec.


Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

vegantriathlete’s picture

Status: Closed (fixed) » Needs work

I have installed the dev version (which does contain the small fix) and I still can't get the caption to display. It doesn't matter whether I use rel="lightbox[][my caption]" or the title (or alt) tags in my anchor. The caption does not display.

Dadaisme’s picture

Status: Needs work » Active

Like vegantriathlete (24th J), I'm using the last dev of lightbox and the caption is still missing.


lastar84’s picture

Well here's something odd that may add to this exchange. I have the beta1 installed and not the dev. I created a gallery page with unlimited images (thumbs that open into the lightbox view and play a slideshow). I added 10 photos and the captions worked fine.

Then removed the photos (due to changing the nature of the gallery) and added 10 more. The captions suddenly stopped working -- or did they? I noted that they worked fine on a second browser in which I was NOT logged in as admin. So, I logged out of the first browser, and now the captions worked. Logged back in as admin, and they stopped working. Logged out and logged back in as a plain ole' authenticated user, and they worked okay.

I'm not sure if this is an isolated quirk, but it is possible that your image captions work fine for non-admin users. It's worth a try if you just want to get the site up and running.

attheshow’s picture

I'm having a similar experience to the above users. I'm using the January 1, 2012 dev version. I'm doing a slideshow via views, using the trigger field. Only anonymous users can see the caption.

Also, for some reason, even thought I have my trigger field's captions set to:
[title]<br />[body]<br />Here is some other text.
...it only shows the content of the [body] field as the caption for the anonymous user.

d_hall’s picture

Totally broken on my D7 site regardless of which version I use. No captions in the lightbox. The first problem with the dev version is the "broken/missing handler" error it gives when you try to add a Lightbox Trigger using Views. Which can be fixed by adding this line of code to lightbox2.info:

files[] = lightbox2_handler_field_lightbox2.inc

DrupalNovice’s picture

Status: Active » Needs review


Changing line 726 in the lightbox.js file from
var caption = Lightbox.filterXSS(Lightbox.imageArray[Lightbox.activeImage][1]);
var caption = Lightbox.imageArray[Lightbox.activeImage][1];
seems to solve the issue for now.

DrupalNovice’s picture

d_hall’s picture

Thanks, but did not work for me.

genjohnson’s picture

Both #18 and #19 do not work for me.

thalemn’s picture

I can also confirm that #18 and #19 did not work for me.

The site I'm building is at: www.melissamollenhoff.com/style-gallery.

Using a view to show the image field with lightbox2 for formatter. Anyone have a work-around so we can put some text with the image in the lightbox display?

d_hall’s picture

One bug I notice is that checking/unchecking "Show image caption" under the Lightbox2 settings only affects whether the "View original image" link appears. It has no effect on whether the caption displays.

StuartJNCC’s picture

The image_caption module works for me (7.x-1.0-beta3). It also creates a caption from the title using java. I must admit I didn't know that lightbox was supposed to do this until I read somewhere else (not Drupal related) that this was its default behaviour. It was only then that I looked for a reason why it wasn't working and found this thread. My worry is, if this module is eventually fixed so that the captioning works as intended, will I end up with two captions? I suppose I only need to disable image_caption if that happens.

El Bandito’s picture


I've just tried Lightbox 2 again a year after my first tussle with this issue in #4. Sadly although I can see from the code that the patch in #8 has now been commited I am still seeing no captions and the html output I am seeing is thus :

<a class="lightbox-processed" title="Andalucia Bike Race : the finish line" rel="lightbox[field_sidebar_images][Andalucia Bike Race : the finish line<p><a href="http://mydomain.co.uk/sites/default/files/bikeracetrips1.jpg"></a></p>]" href="http://mydomain.co.uk/sites/default/files/bikeracetrips1.jpg">
<img width="270" height="180" title="Andalucia Bike Race : the finish line" alt="Andalucia Bike Race : the finish line" src="http://mydomain.co.uk/sites/default/files/styles/sidebar_image/public/bikeracetrips1.jpg">

Again the rel attribute looks corrupt and now I have a stray comma in the html at the end.

I have tried both 7.x-1.0-beta1 and 7.x-1.x-dev.

Any suggestions appreciated.


EDIT: Sorry, the comma seems to be part of my View ( not sure why ) as it still appears after I disable the Lightbox module.

josefnpat’s picture

Status: Needs review » Active

I've gone through about 4 different patches, the 7.x, 7.x-1.x, 7.x-1.x-beta along with a clone of the actual git repo in attempt to find a fix to this solution.

I ended up implementing a workaround, and I thought I would share it.

I needed a clickable image that would open up in a larger lightbox image, and offer a download link (regardless of it being private). Along with the title being the caption.

Here is how I override the view's field template;

Be sure to change field_field_gallery_image to field_field_[field name]!
The gallery thumbnail style ($thumb) image is generated with theme(). (in my case, fourth_gallery)
The url for the larger image style is generated with image_style_url. (in my case, lb2_930)
The original image is pulled out from the row.
The title is extracted from the row.
The entire line is printed out with the proper values substituted.



 * @file
 * This template is used to print a single field in a view.
 * It is not actually used in default Views, as this is registered as a theme
 * function which has better performance. For single overrides, the template is
 * perfectly okay.
 * Variables available:
 * - $view: The view object
 * - $field: The field handler object that can process the input
 * - $row: The raw SQL result that can be used
 * - $output: The processed output that will normally be used.
 * When fetching output from the $row, this construct should be used:
 * $data = $row->{$field->field_alias}
 * The above will guarantee that you'll always get the correct data,
 * regardless of any changes in the aliasing that might happen if
 * the view is modified.
  $img = array();
  $thumb = theme('image_style',$img);
  $lb = image_style_url('lb2_930',$row->field_field_gallery_image[0]["raw"]["uri"]);
  $content_orig = $row->field_field_gallery_image[0]["rendered"]["#path"]["path"];
  $title = $row->node_title;  
<a href="<?php echo $lb; ?>" rel="lightbox[field_gallery_image][<?php echo $title; ?>&lt;p&gt;&lt;a href=&quot;<?php echo $content_orig; ?>&quot;&gt;Download Original&lt;/a&gt;&lt;/p&gt;]" title=""><?php echo $thumb; ?></a>
stephen.punwasi’s picture

Thanks josefnpat, clever solution. I've since given up on this module and started using Yoxview or Colorbox on most of my projects.

scottzee’s picture

Has anyone found a solution to this?

I'm hoping to get some captions on images. Otherwise this is such a great module!

webbymatt’s picture

This is a big, big issue for this module. I've tried various fixes and nothing works - it's looking likely that I'll need to completely remove Lightbox2 and find something else which would be a shame. Any news on fixes from the contributors?

webbymatt’s picture

I have found a solution, hopefully you'll be able to apply it to your own use case:

I have a content type with an image field. I then output these through a View. My title and alt fields were empty which lead me to think there was a problem with the way it was constructed in lightbox.js. Turns out it's being built correctly, I just had to enable and populate the "alt" and "title" attributes within the field in the content type - doh!

I suspect this may be the exact same thing many others are seeing.

thalemn’s picture

Yes, that worked for me! Thank you very much!

MGParisi’s picture

Colorbox will take the page title and put it as the caption!

ykyuen’s picture

In my case, the caption is missing becoz i am using the views galleriffic module. it seems that the #caption cannot be located in the lightbox.js. i bypass the problem by

if (s.show_caption) {
  var caption = Lightbox.filterXSS(Lightbox.imageArray[Lightbox.activeImage][1]);
  if (!caption) caption = '';
    //$('#caption').html(caption).css({'zIndex': '10500'}).show();
    $('#imageDataContainer #caption').html(caption).css({'zIndex': '10500'}).show();

hope it could help.

cmiguel’s picture

Populating fields, that was it!!

Its not the Node Title its the title attribute from IMG tag.

scottzee’s picture

webbymatt, that worked for me! thank you! (d'oh indeed!)

yukare’s picture

Status: Active » Closed (cannot reproduce)

I will close this issue as i can not reproduce it now with current code from git, if someone still have it please reopen this issue, and try to provide me a public site with the error, or meet me at irc #drupal.