Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deekepMaks's avatar

How to change photo description in glightbox?

I'm using a glightbox to view a photo, and in the data-glightbox="description: ... .myDescription ..." parameter, I specify the class for the description box that will open with the photo. I can edit the description of the photo using ajax, then I change the text in the .myDescription class in the required field to the new one, but when I open the photo again, the old description is shown. I tried using lightbox.init() and lightbox.reload() however it didn't help

0 likes
1 reply
aidil's avatar

You can use the destroy() method before init().

Another thing you could try to do is to update the text of the description directly by using the setContent() method of the glightbox, this method allows you to update the content of a slide in the lightbox, so you can update the text of your .myDescription class in this way:

lightbox.setContent(index, {'description': newDescription});

Please or to participate in this conversation.