-
trenzterra
Hi there,
I noticed that Guternberg now has the option to open images and gallery images in a lightbox. However, to get it to open in Lightbox by default, I need to create a theme.json file with the following code:
"core/image": { "lightbox": { "enabled": true } },
However, once I upload this json file to my theme directory, the formatting in my editor seems to be messed up slightly, as instead of the content blocks being center-aligned, they now become left-aligned.
I understand that GP does not normally support theme.json. Is there any other way to support the lightbox feature in GeneratePress?
-
Alvind
Hi there,
You can try this snippet:
add_filter('wp_theme_json_data_default', function ($theme_json_data) { $new_data = [ 'version' => 2, 'settings' => [ 'blocks' => [ 'core/image' => [ 'lightbox' => [ 'enabled' => true ] ] ] ] ]; return $theme_json_data->update_with($new_data); });
Adding PHP: https://docs.generatepress.com/article/adding-php/
This works in my testing, let me know if it works on your end.
-
rrcsoares
Hi Alvind
Is it possible to add a section to this code so that the lightbox looks like a slide gallery?
Thaks
-
Alvind
Not sure about that, though. I didn’t see any reference on how to add that in the WordPress documentation.
- You must be logged in to reply to this topic.