# Better Defaults for New Blocks

> Changes the starting settings of blocks editors add: images link to nothing and open large, galleries crop evenly, columns stay side by side on phones, and new tables have header rows.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: block-editor, defaults, images
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/default-block-settings/

## Code

```php
add_action( 'enqueue_block_editor_assets', function () {
    wp_register_script( 'wpide-block-defaults', false, array( 'wp-hooks', 'wp-blocks' ), '1.0', false );
    wp_enqueue_script( 'wpide-block-defaults' );
    wp_add_inline_script( 'wpide-block-defaults', <<<'JS'
( function ( wp ) {
    // Block name => attribute => new default value.
    var defaults = {
        'core/image': { sizeSlug: 'large', linkDestination: 'none' },
        'core/gallery': { imageCrop: true, linkTo: 'none' },
        'core/columns': { isStackedOnMobile: true },
        'core/table': { hasFixedLayout: true }
    };
    wp.hooks.addFilter( 'blocks.registerBlockType', 'wpide/block-defaults', function ( settings, name ) {
        if ( ! defaults[ name ] || ! settings.attributes ) {
            return settings;
        }
        var attributes = Object.assign( {}, settings.attributes );
        Object.keys( defaults[ name ] ).forEach( function ( key ) {
            if ( attributes[ key ] ) {
                attributes[ key ] = Object.assign( {}, attributes[ key ], { default: defaults[ name ][ key ] } );
            }
        } );
        return Object.assign( {}, settings, { attributes: attributes } );
    } );
} )( window.wp );
JS
    );
} );
```

## Notes

Only affects newly inserted blocks. Delete any line in the defaults object you do not want.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Better Defaults for New Blocks" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
