• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Disable lightbox on images in WordPress using theme.json

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 1097 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 1097 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
Lightbox settings for image on
Lightbox settings disabled and hidden
Lightbox settings disabled and hidden

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


FSE JSON theme.json WordPress

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2026

close-icon

Lost your password?