0

I am looking for hook, that fires right after image uploaded, cropped for thumbnails and data posted to database.

I need it for image optimization after uploading.

I tried add_attachment and it fires before image cropping and my code stuck. Help please!

2
  • How about wp_handle_upload it's a filter that fires after a file is being uploaded Commented Jan 24, 2022 at 12:53
  • This filter fires before image cropped and added to database.
    – Denny
    Commented Jan 24, 2022 at 23:10

1 Answer 1

1

There is to filters needed for optimizing all images, that will be uploaded:

add_filter('wp_handle_upload', 'random_function', 10, 2);
add_filter('image_make_intermediate_size', 'rand_function2', 10, 1);

function random_function($array, $string) {
// Some random action with main image
return $array
}

function rand_function2($file) {
// Some random action with cropped images
return $file
}

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.