Discover in this tutorial how to disable the lightbox effect on images when clicking on them in a WordPress theme using the theme.json file.
The theme.json file allows such a degree of customization of a WordPress theme that it is worth getting familiar with it.
That’s why I’ve published a set of tutorials focused on explaining how it works and, more importantly, how you can customize it to your liking.
Starting with WordPress 6.4, the lightbox feature was added, which allows you to click on an image to expand it. In general it is an interesting option, but it may be that you prefer to disable it and that the option does not appear in the editor.
So in this tutorial we are going to see how you can do it.
Instructions to disable the lightbox in a WordPress theme
1. Modify (or create) the theme.json file
In case your theme already has a theme.json file, find the "settings"
section (if it doesn’t exist, create it at the same level as "styles"
) and add the following.
To see this and another 1091 code snippets of this website, login or subscribe here.
With this you can deactivate the lightbox and also the option to activate it in the editor disappears.
In case the theme does not have one, you have to create a file called theme.json and place it in the root of your theme. I recommend you to take a look at the tutorial where I explain the anatomy of the theme.json file.
Once you have done that, add the following code:
To see this and another 1091 code snippets of this website, login or subscribe here.
2. Interface in the block editor
Once you have added this snippet, either by adding a new theme.json file or by modifying an existing one, you will see that the option to enable “expand on click” disappears.
![Expand on click setting enabled by default](https://osomcode.com/wp-content/uploads/2023/11/Expand-on-click-setting-enabled-by-default-300x162.webp)
![Lightbox settings disabled and hidden](https://osomcode.com/wp-content/uploads/2023/11/Lightbox-settings-disabled-and-hidden-300x114.jpg)
Conclusions
Now you know how to disable the lightbox effect when clicking on images in a WordPress theme using the theme.json file.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉