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!
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!
Share Improve this question asked Jan 24, 2022 at 12:43 DennyDenny 212 bronze badges 2 |1 Answer
Reset to default 1There 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
}
wp_handle_upload
it's a filter that fires after a file is being uploaded – Buttered_Toast Commented Jan 24, 2022 at 12:53