Since WP 3.0 does not support hard crop anymore (the only way to crop is in media manager), how am I suppose to dynamically crop my thumbnails? I don't want to crop them manually one by one...

1 Answer 1




$image = wp_get_image_editor( 'cool_image.jpg' );
if ( ! is_wp_error( $image ) ) {
    $image->rotate( 90 );
    $image->resize( 300, 300, true );
    $image->save( 'cool_image.jpg' );

Repalce cool_image.jpg with a variable holding the path to the image you want to edit. Not a copy and paste solution but should put u on the right track. There is a crop function.

crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ); 
//Crops Image. 
  • Really nice! So this is the class that is used by the image editor in the admin panel?
    – user25893
    Commented Jul 9, 2013 at 14:58
  • 1
    I am not cerain but I have made that assumption. WP_Image_Editor class was added in 3.5.2 I believe. Its good to read those release notes when you update wordpress to see what new bells and whistles they added :).
    – Vigs
    Commented Jul 9, 2013 at 15:00

Your Answer

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