Is there any hook which is triggered when an image is edited (crop/re-size whatever)? I need to send an email notification to an admin user when an image will be edited (crop/re-size whatever). I need to get media/attachment id as well which have to be sent in email.

I need your advice.


wp_save_image_editor_file filter fires after.

add_filter( 'wp_save_image_editor_file', 'custom_wp_save_image_editor_file', 10, 5 );
function custom_wp_save_image_editor_file( $saved, $filename, $image, $mime_type, $post_id ){
    //Your logic here   

    return $saved;

You might try out the image_editor_save_pre filter:

add_filter( 'image_editor_save_pre', 'custom_image_editor_save_pre', 10 , 2 );
function custom_image_editor_save_pre( $image, $post_id){
    // your stuff here

    return $image;

This filter seems to be called when you crop/rotate the image and press the Save button (and it's a pre-filter)

The $image is an object of type WP_Image_Editor_GD and here is an example of how it might look like in the filter:

WP_Image_Editor_GD Object
    [image:protected] => Resource id #172
    [file:protected] => /absolute/path/to/wordpress/install/wp-content/uploads/2013/07/car.jpg
    [size:protected] => Array
            [width] => 220
            [height] => 330

    [mime_type:protected] => image/jpeg
    [default_mime_type:protected] => image/jpeg
    [quality:protected] => 90

and $post_id is the attachment id.

There might be other better hooks to look for, but I found this one in


in this function:

 * Saves Image to File
 * @param string $filename
 * @param WP_Image_Editor $image
 * @param string $mime_type
 * @param int $post_id
 * @return boolean
function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
        if ( $image instanceof WP_Image_Editor ) {
                $image = apply_filters('image_editor_save_pre', $image, $post_id);
                $saved = apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id);

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.