It would be nice to be able to use the "Description" field that is available via FileField (and then through ImageField). I see that there is a config option in the "CCK Display Settings" area where we can "Use node title as caption". It would be nice to have the option to use the Description field that would appear under the Title.
Use case: I have used Views, CCK and Lightbox to to create photo albums. We had a need for long descriptions and short titles but didn't have a separate field for the two roles. As you can see in the example in the link below, we really could have used a short, Title field for the thumbnail display. When clicking on the image, the Lightbox should then show the Title (in bold) and then the Description (not in bold and right under the Title).
http://npower.org/support/events/technology-service-corps-graduation
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | lightbox2-image-body-302642-18.patch | 1.27 KB | arpieb |
Comments
Comment #1
peter_n commentedAnd same for image nodes. Could there be an option to use the body of the image node as the caption when displayed in the lightbox.
Comment #2
stella commentedThe body text for any node can not be the caption in the lightbox, as it could be any length. There is already a solution in place for that. On the automatic settings page (admin/settings/lightbox2/automatic), just choose the "HTML content" handler for "image nodes". If you need to theme this page, then use the page-node-lightbox2.tpl.php that comes with lightbox2 module. It's for the garland theme, but you can easily modify it for your theme - just copy it to your theme's directory and adjust as needed.
I still need to look into showing the imagefield file description in the lightbox. If the text field isn't too long, then I should be able to add it as an option to display.
Cheers,
Stella
Comment #3
stella commentedFixed in the latest dev release, available later today.
Cheers,
Stella
Comment #4
jsheffler commentedWell, almost fixed... :-) In lightbox2.formatter.inc, lines 143 and 144 are now:
But that is probably not what you meant, as line 144 uses $title instead of $image_title. So presumably that line should be:
Even so, the "description" field will only be used here if both the "title" and "alt" tags are empty, which is probably not what capellic had in mind. I would suggest something like the following instead:
Anyway, I hope that helps.
Comment #5
stella commentedjsheffler: thanks. I've gone with the first method (fixing the typos), 'title' and 'alt' are only set for imagefields, and 'description' is only set for filefields, so regardless of the order of description vs title/alt, it should be correctly set.
Cheers,
Stella
Comment #6
jsheffler commentedIt's no big deal to me, but as a point of clarification for those who care, the "description" field is actually available for imagefields, too, since an imagefield is essentially a specialized filefield...
Comment #7
capellicSoooooooooooo sweet!
I hadn't been to my Tracker in a while but just did a bunch of module updates for a site that is about to go live and noticed my Description field is showing up in the Lightbox -------- EXCELLENT!
THANKS!
Comment #8
spidersilk commentedHas this also been fixed for 5.x-2.x-dev? Or if not, is it going to be? I've had a request from a client to include the image descriptions in the lightbox view, and I've stuck with Drupal 5 thus far for any site where image galleries are used because the Image module itself is still in alpha for v.6.
Comment #9
stella commentedThis was only an issue in 6.x-1.x The 5.x version is already using the image description in the lightbox.
spidersilk: note, this issue and fix is only about the 'description' attribute of CCK filefields. We're not referring to the body text of image nodes, etc. If you want to show the body text of image nodes in a lightbox, then please use the "html content" automatic display option, combined with the template file changes from the "Opening node content in a lightbox" section on http://drupal.org/node/252260
Comment #11
extect commentedCurrently, there is the following problem:
Imagefields consist of the following fields: 'title', 'alt' and 'description'. To output valid XHTML you have to enter something for 'alt'. However, the image's description only gets displayed in Lightbox if there was nothing entered for the 'alt'-field. So, currently there does not seem to be any way to output valid XHTML AND display the image's description in Lightbox.
I think, to prevent this problem, we should really change the code to method #2, which jsheffler presented in comment #4.
Comment #12
capellic@extect: Thanks for pointing that out. I was wondering why the "alt" string was showing up in as the caption and not the description field.
Comment #13
stella commentedFixed, will be included in the next dev release, available later today.
Cheers,
Stella
Comment #14
stella commentedReleased in Lightbox2 6.x-1.9 and 5.x-2.9.
Cheers,
Stella
Comment #16
Trunkhorn commentedComment #17
bluestarstudios commentedHey guys. Thanks for all your work...
I'm confused though. I have the latest version and I can't seem to get it to work. Where do I configure this?
I have a cck imagefile field. I have enabled custom titles and descriptions for the images. When I open a Lightbox with the image, the only thing that's being displayed is the description in bold. No title. How do I display the title in bold and the description normally underneath that?
Thanks
Comment #18
twiik commentedI'm often on such short deadlines I can't wait for things to be patched and often have to hack things myself so on the site I'm working on now I hacked in an image description, so I get title in bold with image description below, in the lightbox like this:
I made these changes to Lightbox.js in the js folder of the lightbox2 module:
1. In the initialize function:
I changed this line:
var caption = '<span id="caption"></span>';to this:
Then I add my description to the image details by changing this line:
$('#imageDetails').append(caption + numberDisplay);to this
$('#imageDetails').append(caption + desc + numberDisplay);2. In the updateDetails function:
I duplicated this code:
and changed every reference to caption to desc, and changed 1 to 2 to access the third (alt) element in the array, so I ended up with this:
3. In the start function:
I changed this:
to this
and because on the site I'm setting up now I'm working with grouped images I also changed this:
to this:
I realize this depends on me either writing my imagefield descriptions in the alt field or using the imagefield description as the alt for my images. And Lightbox will now use the image description instead of the image title as alt for the images, but that doesn't bother me. As far as I care it works for this site. :)
I'm guessing it's the lack of extra attributes that makes this hard to fix, but I noticed you can have something like this in the rel attribute "lightbox[group][caption]". Why can't this be "lightbox[group][description]"? We already have the title attribute for our titles. Just a suggestion. :)
Comment #19
jglynn commentedThanks for posting that code, TwiiK, I'll give it a try.
This would be great to have implemented in the lightbox2 module so that both title and description fields could be displayed together for an image. Seems from looking through the issues that many other people would like to see this as well.
Comment #20
arpieb commentedIt looks like this one opens and closes at will, but I did finally find a way to get node descriptions to come up in the lightbox without having to resort to a full page load using the "HTML Content" approach. My biggest motivation was the fact that the D6 site I'm working on is using a migrated old-school theme, so .tpl files aren't even an option - and I'm not about to re-theme the entire site just for this feature.
If anyone is interested, this is all I did to get the image body field to load up:
1. Add the "Node: Body" to the fields selected by the image_gallery view.
2. Added the following snippet to my main CSS file:
3. Then I modified js/lightbox.js per the attached patch against 6.x-1.9.
Pretty similar to TwiiK's solution for using the existing alt element. It ain't pretty, but it does work pretty well. I was trying to avoid rewriting too much of the existing code or messing with the hard-coded array indices... Figured between Views and jQuery I could get the data into the page and in the lightbox display without too much suffering... ;)
Comment #21
bitsize commentedarpieb - Your solution is great. Thank you!
This solution is perfect if you are using a wysiwyg editor on your site. If you are not, do everything as mentioned in this post but change the following two line of code in patch before applying. They are:
and
Should be this:
and
respectively.
Comment #22
archer007 commentedThis patch no longer works with the latest stable version of lightbox2. I have also tried to apply it manually (and followed the patch instructions) without success. Also, there is no view named image_gallery. Does this work any more? Its possible I am just messing things up, but I think there have been code changes that broke the patch.
Comment #23
arpieb commented@archer007 - as noted in my patch comment, it was against the 6.x-1.9 release of the code. It's now at 6.x-1.11, so I'm sure some changes have been made in that area as it appears to be the core of the Lightbox2 JS code. Some adaptation might be required at this point... Unfortunately I'm busy trying to roll out the next release of another module right now, so I can't dig into it myself, and my client hasn't screamed yet for the latest release of Lightbox2 so I haven't had to look into it... ;)
The image_gallery view is defined if you have the Image module installed and have the included Image Gallery module enabled.
Comment #24
odisey commentedSo ...... Is the description field now printing in Lightbox2 when the image pops up? I have the description field when uploading images to a node, and I enter info into it, but nothing prints in the light box. I have not found a setting that seems to enable description fields to print either .... Do we have to hack?
Thanks!
Comment #27
joseph.olstadfixed in 7.x-2.0
if you want this fix then please upgrade to 7.x-2.0