0

I'm trying to give a more complete experience to my WordPress backend users and let them edit the custom image sizes I have added to my theme.

I added this to my functions.php:

add_image_size( 'new_image_size', 500, 500, true );

I would like the new size to be available here:

Editing an image in WordPress

Is there a filter to add one of my custom sizes there?

  • Have you maybe found some real solution to this problem over time? – Luca Reghellin Jun 28 '17 at 10:39
0

I don't think it is possible... i have been looking answer for this also...

check this out... https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/image-edit.php#L134

it seems hard coded... no action or filter in between... Changing the core is not recommended... and i don't think it's doing what we are expected after all...

on Save https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/image-edit.php#L767

it is only check if it is nothumb, all or original.

and the sizes will be loaded from database options. it means all available Image Sizes including the one we add with add-image-size...

it seems we are not be able to edit it one by one at least for now...

1

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

  • This should be the accepted answer as it is possible. – disinfor Sep 29 '16 at 19:37
  • This answer doesn not address the issue at all. – Luca Reghellin Jun 28 '17 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.