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?

1 Answer 1


Your understanding of what the default is, is incorrect. "isDefault for new blocks" would be a more accurate interpretation, those existing blocks are not this variant.

Think of it this way, if I'm building a row of houses then the plans/blueprints are the default. Changing the plans does not magically transform all the houses that have already been built.

You've told WP when a gallery is created, these are the initial attributes to use when setting this variant. So new gallery blocks would have these attributes, assuming this variant.

Remember, variants are presets, if you create a gallery block that is not this variant, give it 6 columns, link to media, no crop, and a thumbnail, then it becomes this variant. Default values are initial values, not permanent dynamic values that change when you change the defaults.

Likewise, if you create a facebook embed, and modify its attributes to insert a twitter URL, then it becomes a twitter embed block, because they are all variants of core/embed. The attributes determine which variant a block is, not the other way around.

  • Tom, excuse me I haven't mentioned that I don't want transform existing content at all. I want to skip WP defaults to my specific settings at every new insert of the Gallery Block - that's the point.
    – Rafiozoo
    Commented Apr 11, 2022 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.