Skip Navigation

[Resolved] Displaying captions in the lightbox display for gallery images

This thread is resolved. Here is a description of the problem and solution.

Problem:
Displaying captions in the lightbox display for gallery images

Solution:
You will have to add the custom JS workaround to display the captions with the lightbox added by gallery image.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/displaying-captions-in-the-lightbox-display-for-gallery-images/#post-2364257

Relevant Documentation:

This support ticket is created 2 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by JoshuaD7497 2 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#2363851

I need to display captions on my gallery images in the lightbox display for each image.

I found a couple of support pages where users had the same requirement, but I couldn't implement the suggested solutions. There were hidden screenshots and links in the support pages which I couldn't view, which probably didn't help.

e.g. https://toolset.com/forums/topic/display-caption-image-in-lightbox/
and https://toolset.com/forums/topic/display-captions-with-lightbox-images/

#2364257

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I've added the following ID to my gallery block: my-gallery
- Please check the following screenshot: hidden link

And then, I've added the following code to the JS box of my content template:
Screenshot: => hidden link

jQuery(function ($) {
    var gallery = $('#my-gallery')
    gallery.find('li').each(function () {
        var caption = $(this).find('figcaption').text()
        
var link = $(this).find('a')
        link.attr('data-title', caption)
    })
});

If you check on frontend, I can see when you click on first three images which have captions setup, it does display the caption with lightbox: hidden link

Here is the sandbox site login if you may require:
- hidden link

#2364301

With your advice, my issue is resolved now. Thank you!