Adding custom image size to the media image editor

As far as i know it is possible with image_size_names_choose hook (see https://codex.wordpress.org/Plugin_API/Filter_Reference/image_size_names_choose).

Example:

// add your custom size
function my_setup_image_sizes() {
  add_image_size( 'wide-image', 900, 0);
}
add_action( 'after_setup_theme', 'my_setup_image_sizes' );

// add custom size to editor image size options
function my_editor_image_sizes( $sizes ) {
    $sizes = array_merge( $sizes, array(
      'wide-image' => __( 'Image 900px wide' )
    ));
    return $sizes;
}
add_filter( 'image_size_names_choose', 'my_editor_image_sizes' );

NOTE You will have to regenerate thumbnails if you would like to define new image size for existing images

NOTE 2 Base image size has to be greater than dimensions specified inside add_image_size function

Leave a Comment