I have a function to add EXIF information to an image after the image is uploaded to a website. How do I get the EXIF information to be automatically added to the image after the image is uploaded or added to the post?
I have tried some hooks like the following to check for failed photo uploads and started executing the function to add EXIF info but it doesn't work. add_attachment
, wp_handle_upload
and wp_handle_upload_prefilter
. Whenever an image is uploaded through adding to the post, it gives an error that the image could not be uploaded.
Below is an example of my code. Every time I select an image to add to a post, I get a message like this. Please help me. Thank you very much!
An error occurred in the upload. Please try again later.
function custom_to_all_image($upload) {
if (wp_attachment_is_image($attachment_id)) {
//my function
}
return $upload;
}
add_filter( 'wp_handle_upload', 'custom', 10, 2 );
echo
on image upload as those happen during AJAX calls and there'd be no way to see your output, it'd also break the AJAX response! That's why the post editor says image could not be uploaded. What are you trying to do that requires this? It sounds like an X Y problem were you asked how to implement your fix not how to solve the problem. I read the initial few sentences that try to explain this but it didn't make much sense. What does reprocessing do? Are you trying to optimise images? Making your Q more specific will get you more/better answers