• Hi,

    I would like to change the block preview image, for my Gallery Block Variation.
    Is it possible ?

    I found this with ‘example>attributes’ digging the internet but it’s not working.

    wp.blocks.registerBlockVariation(
    'core/gallery',
    {
    ...custom stuff...
    example: {
    attributes: {
    cover: "https://www.mywebsite.com/wp-content/themes/mytheme/assets/blockpreview.jpg",
    },
    viewportWidth: 800
    },
    isDefault: true
    }
    );


    Thank you for help

    • This topic was modified 1 year, 6 months ago by charlie67p.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    the preview is not an image but a live block preview, see the example>attributes in the core/gallery block itself:

    example: {
    	attributes: {
    		columns: 2,
    	},
    	innerBlocks: [
    		{
    			name: 'core/image',
    			attributes: {
    				url: 'https://s.w.org/images/core/5.3/Glacial_lakes%2C_Bhutan.jpg',
    			},
    		},
    		{
    			name: 'core/image',
    			attributes: {
    				url: 'https://s.w.org/images/core/5.3/Sediment_off_the_Yucatan_Peninsula.jpg',
    			},
    		},
    	],
    },

    So I’d recommend to just use the above example and change the images to your liking.

    Thread Starter charlie67p

    (@charlie67p)

    Great!! Thank you @akirk !

    Thread Starter charlie67p

    (@charlie67p)

    Well, I’m trying in many ways to make the gallery block preview bigger, via Block Variation and via Css, but I don’t find.

    Can we add a custom size ?

    • This reply was modified 1 year, 6 months ago by charlie67p.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘block variation change block preview image’ is closed to new replies.