Center Inserted Images by Default
Makes images inserted in the classic editor and the media window centered by default instead of having no alignment, which suits most single-column blogs.
Opens WPIDE on
Code
// Default alignment for inserted images.
$wpide_image_align = 'center';
add_filter( 'pre_option_image_default_align', function () use ( $wpide_image_align ) {
return $wpide_image_align;
} );
Notes
Change $wpide_image_align to left, right or none.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.