Custom default settings for WP native Gallery Block
I've started with MarkJ's answer - JavaScript included into the block editor.
I wanted to control more attributes for gallery than linkTo
— the number of columns, cropping, and image size.
wp.domReady( function() {
wp.blocks.registerBlockVariation(
'core/gallery', {
isDefault: true,
attributes: {
columns: 6,
imageCrop: false,
linkTo: 'media',
sizeSlug: 'thumbnail', // does NOT work in WP 5.9.3
}
}
);
});
This snippet does the job partially. In WP editor block settings panel it looks like OK.
Unfortunately, in fact the size of every image in the gallery remains large
. Still needs an intervention (change to another size, then back to thumbnail
).
Is this a sizeSlug
bug, or
is there a better way to achieve custom defaults for Gallery Block?
Topic block-editor media-settings gallery customization Wordpress
Category Web