customization – 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() {
        '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.

WP Gallery Block Settings

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?

Rafiozoo 10 months 2022-04-11T03:51:16-05:00 0 Answers 0 views 0

Leave an answer