Title: Set default image alignment
Last modified: December 30, 2020

---

# Set default image alignment

 *  [primitivenet](https://wordpress.org/support/users/primitivenet/)
 * (@primitivenet)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/set-default-image-alignment/)
 * 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 12 replies - 1 through 12 (of 12 total)

 *  [chenz2](https://wordpress.org/support/users/chenz2/)
 * (@chenz2)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-13856464)
 * I have the same problem. I can get other blocks to align center by default but
   the core/image block doesn’t seem to work with the same codes that work with 
   the other blocks.
 *  Thread Starter [primitivenet](https://wordpress.org/support/users/primitivenet/)
 * (@primitivenet)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-13911351)
 * Does anyone have any ideas here? This seems like it should be a standard feature
   that can be overridden. Am I missing something?
 *  [Babak Fakhamzadeh](https://wordpress.org/support/users/mastababa/)
 * (@mastababa)
 * [5 years ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-14307921)
 * According to this:
 * [https://writenowdesign.com/blog/wordpress/wordpress-how-to/change-wordpress-default-image-alignment-link-type/](https://writenowdesign.com/blog/wordpress/wordpress-how-to/change-wordpress-default-image-alignment-link-type/)
 * Try this:
 *     ```
       add_action( 'after_setup_theme', 'wnd_default_image_settings' );
   
       function wnd_default_image_settings() {
       	update_option( 'image_default_align', 'left' );
       	update_option( 'image_default_link_type', 'none' );
       	update_option( 'image_default_size', 'large' );
       }
       ```
   
 *  [Babak Fakhamzadeh](https://wordpress.org/support/users/mastababa/)
 * (@mastababa)
 * [5 years ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-14307923)
 * (Adding another comment to get updates on this thread.)
 *  [jageo](https://wordpress.org/support/users/jageo/)
 * (@jageo)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-14832325)
 * I’ve been looking for this answer for a while too – tho’ i’m trying to make images
   align right. I have found that [@mastababa](https://wordpress.org/support/users/mastababa/)‘
   s code works for the default_link_type and default_size but i’m not seeing the
   image align work. (admittedly, they get the code from a post dated 2014, so not
   a complete surprise that all components remained unchanged)
 * I found a more current post here (2021), providing a little bit easier way to
   access the defaults:
    [https://blogambitious.com/automate-image-formatting-wordpress/](https://blogambitious.com/automate-image-formatting-wordpress/)(
   and cursed myself for not remembering the options page. Doh!)
 * When i visit the options page, i can see that I have successfully changed the
   default setting for image_default_align to “right”, Yet when i make a post, that
   right alignment isn’t being applied as the default setting. The link type and
   the size are the two that I MOST wanted fixed, so i’m happy for now, but i will
   continue to hunt down the alignment answer.
 *  [espressivo](https://wordpress.org/support/users/espressivo/)
 * (@espressivo)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-14835604)
 * Same – the 2014 article and the blogambitious article do not work. I can see 
   that the wp-options say center and full-size but it has no effect on adding an
   image to the block editor. It still defaults to left, large.
 *  [etiennesamson](https://wordpress.org/support/users/etiennesamson/)
 * (@etiennesamson)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-14850500)
 * Hi,
 * I think it works doing that way.
 *     ```
       // changing default gutenberg image block alignment to "center"
       function change_default_gutenberg_image_block_options (){
         $block_type = WP_Block_Type_Registry::get_instance()->get_registered( "core/image" );
         $block_type->attributes['align']['default'] = 'center';
       }
       add_action( 'init', 'change_default_gutenberg_image_block_options');
       ```
   
 * Hope it will help, let me know.
    -  This reply was modified 4 years, 7 months ago by [etiennesamson](https://wordpress.org/support/users/etiennesamson/).
    -  This reply was modified 4 years, 7 months ago by [etiennesamson](https://wordpress.org/support/users/etiennesamson/).
 *  [jageo](https://wordpress.org/support/users/jageo/)
 * (@jageo)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-14852435)
 * [@etiennesamson](https://wordpress.org/support/users/etiennesamson/) Thanks. 
   That worked for me. I changed the align default to ‘right’ for my needs and it’s
   working.
 * I was curious about what attributes were there to be poked at and found this 
   page here, seemed pretty handy so i thought i would share.
    [https://design.oit.ncsu.edu/docs/gutenberg/block-attributes/#block-coreimage](https://design.oit.ncsu.edu/docs/gutenberg/block-attributes/#block-coreimage)
 * J A
 *  [etiennesamson](https://wordpress.org/support/users/etiennesamson/)
 * (@etiennesamson)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-14853965)
 * Hi [@jageo](https://wordpress.org/support/users/jageo/).
 * Thank you for that page 🙂
    It is very usefull, just missing the available possibilities
   for each attributes.
 *  [devenamul](https://wordpress.org/support/users/devenamul/)
 * (@devenamul)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-15193866)
 * [@etiennesamson](https://wordpress.org/support/users/etiennesamson/) Can you 
   please tell me how to change font size of media-text block?
    please check the
   image [https://prnt.sc/24cjtfi](https://prnt.sc/24cjtfi)
    -  This reply was modified 4 years, 3 months ago by [devenamul](https://wordpress.org/support/users/devenamul/).
 *  [formerfatguy](https://wordpress.org/support/users/formerfatguy/)
 * (@formerfatguy)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-15420240)
 * HA! how awesome. Thanks [@etiennesamson](https://wordpress.org/support/users/etiennesamson/)
 *  [rodolfoalexander](https://wordpress.org/support/users/rodolfoalexander/)
 * (@rodolfoalexander)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-15744502)
 * Is there any way to get all the images in all existing posts to align center?

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Set default image alignment’ is closed to new replies.

 * ![](https://ps.w.org/gutenberg/assets/icon-256x256.jpg?rev=1776042)
 * [Gutenberg](https://wordpress.org/plugins/gutenberg/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gutenberg/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gutenberg/)
 * [Active Topics](https://wordpress.org/support/plugin/gutenberg/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gutenberg/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gutenberg/reviews/)

## Tags

 * [center align](https://wordpress.org/support/topic-tag/center-align/)
 * [image alignment](https://wordpress.org/support/topic-tag/image-alignment/)
 * [left align](https://wordpress.org/support/topic-tag/left-align/)

 * 12 replies
 * 9 participants
 * Last reply from: [rodolfoalexander](https://wordpress.org/support/users/rodolfoalexander/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/set-default-image-alignment/#post-15744502)
 * Status: not resolved