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.
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.
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:
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.
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. 😉