# 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.

- Type: PHP
- Runs: Run everywhere
- Category: [Media](https://wpide.com/library/category/media/)
- Tags: images, alignment, editor
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/media-default-align-center/

## Code

```php
// 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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Center Inserted Images by Default" 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/
