I'm using this function in functions.php
add_filter( 'wp_generate_attachment_metadata', 'delete_fullsize_image' );
function delete_fullsize_image( $metadata )
{
$upload_dir = wp_upload_dir();
$full_image_path = trailingslashit( $upload_dir['basedir'] ) . $metadata['file'];
$deleted = unlink( $full_image_path );
return $metadata;
}
Example:
I have specified that the maximum size of the images will be 300x300, when sending a 350x350 image it will crop the image to the size of 300x300 and delete the original image of 350x350.
How can this be done?