David Stockdale's Scrapcode

Set Default Image Alignment

This is a quick and simple way to set the default alignment of any new image blocks on your website.

Simply add this code to your “functions.php” (with “wide” being replaced with whatever you want your default alignment to be):

add_filter( 'block_type_metadata', 'set_image_auto_wide' );
 * Makes all new images alignment
 * wide by default (David Stockdale).
function set_image_auto_wide( $metadata ) {
  if ( 'core/image' !== $metadata['name'] ) {
    return $metadata;
  $metadata['attributes']['align']['default'] = 'wide';
  return $metadata;

If this helps you leave a like or a comment!

Leave a Reply