The Divi Theme can display a featured image at the top of posts. By default this is a static, non-clickable image. But what if you want to be able to click on the featured image and view the original (full-size) image in a lightbox? Here's how you can do it.
Open Featured Images in a Lightbox using PHP
There are two problems to be addressed when trying to open featured images in a lightbox.
The first is that that we need something to click to trigger opening the image in the lightbox. We'll take care of this by wrapping the featured image in a link, and setting the link URL to the same as the image source. We also add a lightbox class so that Divi will open the image in a lightbox, rather than letting the browser open it as a new page.
The second problem is that Divi replaces the original image with a scaled down version (assuming the original image is larger than the displayed size of the featured image. Opening the image in a lightbox is probably a bit pointless if we aren't going to see a larger version of the image. To address this, we prevent Divi from using a scaled down version of the image. Divi will resize the original to fit the featured image area, but now when we open it a lightbox we'll see a larger version.
Here's the PHP code to make these changes and allow Divi featured images to be opened in a lightbox:
Related Post: Adding PHP to the Divi Theme