Support » Plugin: Gutenberg » Set default image alignment

  • primitivenet

    (@primitivenet)


    Is there some way to make the image block default to center-aligning images?

    I have tried overriding the block in JS using the following code and properly enqueued, but the result is I get two alignment buttons in the editor, which cannot be correct?

    // Modify settings for Core blocks
    wp.hooks.addFilter( 'blocks.registerBlockType',
      'my/change_alignment', ( settings, name ) => {
    
      switch( name ) {
        case 'core/image':
        return lodash.assign( {}, settings, {
          supports: lodash.assign( {}, settings.supports, {
            align: [ 'center']
        } ),
      } );
    }
    
    return settings;
    
    });

    Any help would be appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.