How to show image captions in a WordPress lightbox

How to show an image with a caption or author information in a lightbox in WordPress.

WordPress 6.4 introduced an option to extend images on click and show a larger version in a lightbox. Learn more about the WordPress image lightbox below and how to make lightbox captions appear as well.

Until now, I used third-party plugins, which I will now remove step by step from many of my sites.

Show an image in a lightbox

To extend an image, insert it into the block editor and find the “Expand on click” checkbox in the block options.

Expand on click option in WordPress to show an image in a lightbox.
(Click to see the whole screen)

Right now, you need to enable this option for each image individually. I believe that a general option to extend all images by default might be added in a future release.

The image will extend when a user clicks on it in the frontend when enabled. The visualization of this is also known as a “lightbox” or “fancy box.”

Note: The lightbox option is disabled when the image is wrapped in a link.

Lightbox Caption is missing

The WordPress image lightbox does not show the image caption in the editor or the media library.

This is not a deal breaker to me, though I consider captions helpful – if used correctly.

Luckily, the lightbox caption with author attributions show up, if managed through Image Source Control.

Author information shows up

The author information overlay, added by Image Source Control, was also missing when I tested the first release candidates for the WordPress image lightbox feature in version 6.4.

Eventually, the lightbox caption started appearing with changes closer to the release date.

I only had to change some CSS to make a few overlay positions compatible with extended images.

You can see it working in the animation above.

With this feature’s current momentum, I expect a few changes in the next releases and will try to test them for compatibility.

Questions from readers

What is a lightbox in WordPress?

The WordPress lightbox we cover here opens an image when clicked in a large overlay above the content to see more details. It has been a feature of WordPress since version 6.4.

Are galleries supported?

As of February 2024, one can enable the lightbox option for individual images in a gallery, but there is no navigation between images yet. There are feature requests for this in the core, but no deadline is given.

Are there more WordPress Lightbox settings?

There are no additional options for the WordPress image lightbox in version 6.4. You can only enable them on a per-image basis in the block settings. I am sure that more options will come in the next releases.

Conclusion

The lightbox feature will replace dedicated plugins on many sites. I am excited to use it myself.

However, on this very site, I am still using Easy FancyBox. It supports lightboxes on more than just images, and I can show a different picture in the lightbox than the original one, which I did above when showing the block option. The first animation in the content uses the new WordPress lightbox.

Portrait of Thomas Maier, founder and CEO of Image Source Control

Questions? Feedback? How can I help?

Reach out directly via the contact form.