Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Lightbox and theme.json

  • 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?

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

  • Hi Alvind

    Is it possible to add a section to this code so that the lightbox looks like a slide gallery?

    Thaks

  • Not sure about that, though. I didn’t see any reference on how to add that in the WordPress documentation.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.