In WordPress 6.4, the core image block now comes with a lightbox toggle, labeled as “Expand on click.” Activating it for your image will produce the result below.
The documentation also mentions that you can enable it site wide through the Site Editor. However, if you’re running a non-block/hybrid theme, you don’t have access to that functionality. What else can you do?
Well, it turns out you can also enable it via the theme.json
file, under the settings.blocks
section like so.
"settings": {
"blocks": {
"core/image": {
"lightbox": {
"enabled": true
}
}
}
}
Using this code will automatically enable the toggle on all newly added images, but won’t turn on the lightbox functionality for any previously added core image blocks.
One other note: while you can also turn it on individually for each image in a gallery, it does not allow users to move between the images using arrow keys or swiping. Each image lightbox is still treated individually, though I believe enhancements are being planned for WordPress 6.5!