The filter inside ~/wp-admin/includes/image.edit.php
looks like this:
apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id);
So a callback would look like the following:
add_filter( 'wp_save_image_editor_file', 'wpse91038_saved_image_editor_file', 10, 5 );
function wpse91038_saved_image_editor_file( $saved, $filename, $image, $mime_type, $post_id )
{
var_dump( $saved );
var_dump( $filename );
var_dump( $image );
var_dump( $mime_type );
var_dump( $post_id );
return $saved;
}
Right above the core filter, there’s another filter:
apply_filters('image_editor_save_pre', $image, $post_id);
The result of this filter, is then used as the 3rd argument inside the wp_save_image_editor_file
-filter.
Then there’s another important thing to note: If your custom wp_save_image_editor_file
callback/function returns anything that is not NULL
, then the core function will abort:
if ( null !== $saved )
return $saved;
return $image->save( $filename, $mime_type );
So you either do the $image->save( $filename, $mime_type );
inside your callback, or you will be left with an image that doesn’t get saved. And if you want to do so, then better don’t return the $saved
with no value/NULL
.