When viewing an image within a gallery, the image caption is not appearing below the image. Instead, the gallery description appears there.

CommentFileSizeAuthor
#13 node_gallery_lightbox2.module.patch1.33 KBdbeall

Comments

dddave’s picture

Version: 6.x-2.0-alpha1 » 6.x-2.0-alpha2

Confirmed in alpha2. Also the text doesn't show in the lightbox view.

dddave’s picture

Title: Image caption not appearing below image » Image caption not appearing below image in lightbox view
Version: 6.x-2.0-alpha2 » 6.x-2.0-alpha7
Category: bug » task

Setting to "Choose the content you want to display: Images" solves this for the normal display now. Saddly lightbox is not picking the caption up (which lightbox can do). I consider this a task rather than a bug but feel free to correct me.

kmonty’s picture

Version: 6.x-2.0-alpha7 » 6.x-2.x-dev
Component: Miscellaneous » Lightbox2 Contrib

Yes, this is definitely an issue that needs to be address at some point.

mblataric’s picture

Not sure if opening new ticket is required since this two things relate to lightbox window, same as title not showing.

1. Zoom feature does not work. Lightbox resizes itself to fit window when larger image is loaded, but does not show Zoom button. This behavior works fine with Image module, so i'm guessing it has to do with integration of gallery image and lightbox 2

2. It would also be very nice if lightbox would have link "View original image" (and ability to choose preset for it or simply link original image) - this also works with Image module.

kvoltz’s picture

Is this something that is being addressed? It seems to be a bit quiet at the moment, but this is a feature I would definitely like to have. I made the fatal flaw of showing my client the lightbox before noticing this issue was present. Now I am in a bit of a bind.

kmonty’s picture

@kvoltz - it is something that needs to be addressed but it isn't happening right now. The module maintainers are extremely busy themselves and there are more pressing needs with this module. If you have a client sponsoring your development time, why don't you contribute a patch? It helps everyone out.

kvoltz’s picture

To be honest... I would love to, but I am still a bit new to the whole PHP world. I am getting there... give me another year or so, and I should be contributing. Until then, I will have to find simpler alternatives.

Thanks for your quick response, though!

arnaudfischer’s picture

Subscribing. Has anybody found a way to add "Title", "Caption", "Details", "Print" links to images from Node Gallery displayed inside the Lightbox window? I might have missed it but searching around this issue I did not find anything. This is an important feature, although I understand you guys are busy. Awesome module! Thank you.

-arnaud

mettam’s picture

I'm interested in getting this issue solved as well. At the very least, I'd like to see image titles show up in the lightbox view.

I've looked into this enough to see that Node Gallery isn't passing the title to the link when that's put together in the code. By that I mean you get <a href="http://www.example.com/sites/default/files/imagecache/node-gallery-display/myimage1.jpg" rel="lightbox"> without a title="something" or an alt="something". Looking at the Lightbox 2 module, it just needs to see that title or alt tag to add the text to the lightbox view.

I'm still fairly new to Drupal and haven't done much on the programming side of it, otherwise I'd just figure out the fix myself. Maybe the title isn't getting passed to the image array?

Anyways, thanks for the great module!

dddave’s picture

If you could provide a patch, that would be pure gold. If you (like me) cannot provide patches please share any solution you find. I really hope this problem can be solved in the next release.

UdarEC’s picture

U`r certainly right. we just have to add title="something" to the image link to fix this bug. I`ll try to fix this and post a patch.

UdarEC’s picture

Here is a fast fix.
Open file node_gallery/contrib/node_gallery_lightbox2/node_gallery_lightbox2.module
Find function node_gallery_lightbox2_preprocess_gallery_image_thumbnail.
We need to make it look like this:

function node_gallery_lightbox2_preprocess_gallery_image_thumbnail(&$vars) {
$image = $vars['image'];
$config = $vars['config'];
$mode = $vars['mode'];

switch ($mode) {
case NODE_GALLERY_VIEW_TEASER:
if ($config['teaser']['gallery_display_type'] == 'lightbox2_gallery') {
$image_tag = theme('image_view', $config['image_size']['thumbnail'], $image);
$vars['image_output'] = l($image_tag, imagecache_create_url($config['teaser']['lightbox2_gallery'], $image->filepath),
array('html' => TRUE, 'attributes' => array('title' => $image->title,'rel' => 'lightshow['. $image->gid .']')));
}
break;
case NODE_GALLERY_VIEW_IMAGE_LIST:
if ($config['gallery']['gallery_display_type'] == 'lightbox2_gallery') {
$vars['image_output'] = l(theme('image_view', $config['image_size']['thumbnail'], $image),
imagecache_create_url($config['gallery']['lightbox2_gallery_preset'], $image->filepath),
array('html' => TRUE, 'attributes' => array('title' => $image->title,'rel' => 'lightshow[hi]')));
}
break;
}
}

That`s all)

dbeall’s picture

Status: Active » Needs review
StatusFileSize
new1.33 KB

@UdarEC, It works great!
See it work here, http://www.davebeall.com/node-gallery-gallery2/old-buckeye-lake-park

Every one will thank you for this. Made a patch from #12
as dddave would say, it's gold!

EDIT: my patch should have full path in the index.
Index: node_gallery/contrib/node_gallery_lightbox2/node_gallery_lightbox2.module

Tally’s picture

Thanks. The patch works great for the images on the Gallery pages.

It would be perfect if it worked for the images on the Image page and thumbnails shown through Views.

dbeall’s picture

now I am trying to figure out the body or caption display for lightbox using the example in #12

I think the views is an additional issue. A handler call in (node_gallery.views.inc)
example: 'handler' => 'node_gallery_handler_field_fid',

kmonty’s picture

Status: Needs review » Patch (to be ported)

Mind you, you are only defining the title and not the caption, which was the original request. Solid change, regardless.

kmonty’s picture

Status: Patch (to be ported) » Fixed

Just committed this patch. I know people are interested in potentially displaying more than the title, in which case we can reopen the ticket.

dbeall’s picture

I am attempting a look at this, I have a few ideas (additional variable config strings in the contrib module) and there is some discussion about this in the Drupal community.
I might not get anywhere with it, but looking at it anyway. Will report with any progress.

UdarEC’s picture

Status: Fixed » Patch (to be ported)

Good luck, guys)

dbeall’s picture

Status: Patch (to be ported) » Fixed

Thanks UdarEC, this is in there.. Stop by anytime!

UdarEC’s picture

People, is there any ability to show not only the title, but the caption too? I have no idea about this.

Yaroslav_ki’s picture

Yaroslav_ki’s picture

May be use this option of Lightbox2 http://drupal.org/node/276378?, and send not an image, but full image node?

dbeall’s picture

a work around for the caption in lightbox..
posted by DesignWork

I think I found a solution which is more convenient for the lightbox problem.
As I remember lightbox uses the alt text of the images to display as caption.

So in your function (theme.inc)

function theme_image_view($imagecache, $image) {
  return theme('imagecache', $imagecache, $image->filepath, $image->title, $image->title);
}

you call twice the $image->title as attribute for theme imagecache. Instead of this you should use it like this

function theme_image_view($imagecache, $image) {
if (!empty($image->body)){
$alt = $image->body;
} else {
$alt = $image->title;
}
  return theme('imagecache', $imagecache, $image->filepath, $alt, $image->title);
}

Cheers
Dirk

kmonty’s picture

I would be worried about injecting that much code into an alt attribute. There must be a better solution.

dbeall’s picture

i don't know any php yet, so I am in the dark on all this. I just figured it belonged in this thread.
Designwork had it working on his site, but I can't get it to work, there must be some trick to it..

designwork’s picture

Hi kmonty,

we could wrap the image->body with with check_plain($image->body) so its more secure. But for SEO this is also better if the alt tag of an image is different from the title. We could also cut it with

 if (drupal_strlen($image->body) > 25) {
 		$alt = check_plain(drupal_substr($image->body, 0, 25));
 			}
		 else {
 		$alt = check_plain($image->body);
 		}

or you can only change the following function like mentioned on this thread.

function node_gallery_lightbox2_preprocess_gallery_image_thumbnail(&$vars) {
$image = $vars['image'];
$config = $vars['config'];
$mode = $vars['mode'];

switch ($mode) {
case NODE_GALLERY_VIEW_TEASER:
if ($config['teaser']['gallery_display_type'] == 'lightbox2_gallery') {
$image_tag = theme('image_view', $config['image_size']['thumbnail'], $image);
$vars['image_output'] = l($image_tag, imagecache_create_url($config['teaser']['lightbox2_gallery'], $image->filepath),
array('html' => TRUE, 'attributes' => array('title' => $image->title, 'alt' => $image->body, 'rel' => 'lightshow['. $image->gid .']')));
}
break;
case NODE_GALLERY_VIEW_IMAGE_LIST:
if ($config['gallery']['gallery_display_type'] == 'lightbox2_gallery') {
$vars['image_output'] = l(theme('image_view', $config['image_size']['thumbnail'], $image),
imagecache_create_url($config['gallery']['lightbox2_gallery_preset'], $image->filepath),
array('html' => TRUE, 'attributes' => array('title' => $image->title, 'alt' => $image->body,'rel' => 'lightshow[hi]')));
}
break;
}
}

Cheers

Dirk

designwork’s picture

Hi dbeall,

I´m not using lightbox2. This is a different js, that makes an automated slide show with thumbnails, timer ect. of the Images in a gallery. I`m thinking to make a contrib module with a few js and a hook form alter to inject more display option for galleries.

Cheers

Dirk

Status: Fixed » Closed (fixed)

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

RedTop’s picture

Version: 6.x-2.x-dev » 6.x-2.0-alpha11
Status: Closed (fixed) » Active

I too would like lightbox to display the caption. I have tried both suggested workarounds, but none seem to have the desired effect. Any progress on this?

kmonty’s picture

Version: 6.x-2.0-alpha11 » 6.x-2.x-dev
Status: Active » Closed (fixed)

Test the latest dev release before reopening issues.

robray’s picture

There a couple of people in a bind (as I was) with no caption displaying in Lightbox2 when using node_gallery.

If you don't care about the Image title, you can swap caption for the title with relative ease.

WARNING: this is not long term fix, this should not be a patch, this shouldn't be contributed to any sort of public source control system, etc. This is a HACK. But it is quick and easy, and just might get a client off your back for a while until a better solution is in place.

This will require editing two cases in

node_gallery_lightbox2.module's node_gallery_lightbox2_preprocess_gallery_image_thumbnail function.

case NODE_GALLERY_VIEW_TEASER: and case NODE_GALLERY_VIEW_IMAGE_LIST:

to

array('title' => $image->body

You will also probably want to edit the lightbox.css to make the caption pretty.
Ex: de-bolding the font weight, making the imageData width something longer than 70% etc.

- Rob

mikeyw’s picture

Another option to get the caption working is to add a second set of '[]' to the rel attribute as described in the lightbox2 module help: "Optional: To show a caption either use the title attribute or put in the second set of [] of the rel attribute."

So here is the code that works for me in node_gallery_lightbox2_preprocess_gallery_image_thumbnail:
...
case NODE_GALLERY_VIEW_TEASER:
if ($config['teaser']['gallery_display_type'] == 'lightbox2_gallery') {
$image_tag = theme('image_view', $config['image_size']['thumbnail'], $image);
$vars['image_output'] = l($image_tag, imagecache_create_url($config['teaser']['lightbox2_gallery'], $image->filepath),
array('html' => TRUE, 'attributes' => array('title' => $image->title, 'rel' => 'lightshow['. $image->gid .'][' . check_plain($image->body) . ']')));
}
break;
case NODE_GALLERY_VIEW_IMAGE_LIST:
if ($config['gallery']['gallery_display_type'] == 'lightbox2_gallery') {
$vars['image_output'] = l(theme('image_view', $config['image_size']['thumbnail'], $image),
imagecache_create_url($config['gallery']['lightbox2_gallery_preset'], $image->filepath),
array('html' => TRUE, 'attributes' => array('title' => $image->title, 'rel' => 'lightshow[hi][' . check_plain($image->body) . ']')));
}
break;
...

technicka’s picture

Is this functionality now part of any release of Node Gallery? I am running version 6.x-2.0-alpha10 and I am still having the issue. Would be great if both caption and title were available in Lightbox view.

Thank you

PS: I tried 6.x-2.0-beta2 and now I get a title but still no caption.

justintime’s picture

AFAIK, the lightbox2 contrib module will go away with NG3, because the straight-up lightbox module supports views and cck. I haven't personally tried it, but it should be fairly easy to do.

dokpm0’s picture

The comments here have been very helpful. I didn't know about the option to pass additional markup via the rel tag. That's much easier than the method I've been using on my site, which I'm working on converting to Drupal. With the notes here I've managed to duplicate the lightbox functionality from my site using node_gallery. If there's a caption it displays title - caption followed by a separate paragraph with a "bookmarkable view" link pointing to the non-lightbox node_gallery image view, an "original size" link, and a "lightbox navigation help" link pointing to a page with info on the keybaord shortcuts, etc. Many thanks to the node_gallery and node_gallery lightbox2 developers!!!

Amyfers’s picture

The caption doesnt work for the recent versions of Lightbox, like 6.1.11 :(

Instead, uninstall your current lightbox and go here: http://drupal.org/node/55200/release

Scroll down to lightbox2 6.x-1.9 and download, install, enjoy your captions :)

mikedotexe’s picture

This is so weird because I have a development site where the latest version works, but it won't work on my live site. My IT guys who run the server say that configurations are identical. I'm pulling my hair out trying to find the difference.

asad.hasan’s picture

Quick javascript theme hack:

Drupal.behaviors.fixCaptions = function() {
	$('#lightbox').live("DOMSubtreeModified", function() {
		$('#caption').html($('#lightboxImage').attr('alt')); //use title if u are using title for caption
	});
}

Won't work in old browsers because it depends on a new js event.