2

I'd like to increase the size of the preview image on the media edit page. At the moment it's too small to accurately crop.

../wp-admin/post.php?post=2758&action=edit&image-editor

image edit page

4
  • yes, that's possible, I managed to do that via the image_resize_dimensions filter from the resize part of the image editor class. But I'm not sure how useful that is since the javascript crop selection numbers will then not be accurate.
    – birgire
    Commented Oct 6, 2015 at 11:19
  • @birgire As you say, this breaks the crop javascript which defeats the point in this instance! Thanks for your input anyway.
    – benc
    Commented Oct 6, 2015 at 12:00
  • Solution: get a bigger screen.
    – matthew
    Commented Oct 6, 2015 at 13:32
  • 1
    Here's my draft on gist, without modifying core. I'm afraid bigger screen won't work becaue of the 400 limit ;-) @hobobob
    – birgire
    Commented Oct 6, 2015 at 13:59

1 Answer 1

4
+50

Its not possible unless you modify the core.

File: wp-admin/includes/image-edit.php

line number 28 in wp_image_editor function

$sizer = $big > 400 ? 400 / $big : 1;

line number 346

function _image_get_preview_ratio($w, $h) {
    $max = max($w, $h);
    return $max > 400 ? (400 / $max) : 1;
}

This function is responsible for small image preview as you can see 400 / $max is fixed. If you change 400 to 800 it works fine on my system.

Best possible way but partially working script.

It only change the size of the image but unable to update the parent image size so javascript not properly work here.

add_filter( 'image_editor_save_pre', 'custom_image_editor_save_pre', 10, 5 );
function custom_image_editor_save_pre( $image, $post_id ){

     $temp = wp_get_image_editor( $post->guid );
     if ( ! is_wp_error( $temp ) ) {
          // calculate height in the ratio of width
          $temp->resize( 800, 400, true );
     }
     return $temp;
 }

Here is the ticket I raised for enhancement purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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