Click to enlarge every image
Switches on WordPress’s built-in lightbox for all Image blocks, so visitors can click any image to see it full size. Editors can still turn it off per image.
<?php
add_filter(
'wp_theme_json_data_theme',
static function ( $theme_json ) {
return $theme_json->update_with(
array(
'version' => 3,
'settings' => array(
'blocks' => array(
'core/image' => array(
'lightbox' => array(
'enabled' => true,
'allowEditing' => true,
),
),
),
),
)
);
}
);
Good to know
For images added with the block editor. Images linked to a page or file keep their link instead.
In these packs
- Posts and the editor: Make the block editor calmer and give pages excerpts, tags and categories.
- Images and media: Sharper, lighter images, tidier uploads and a more useful media library.