7

When a media (image) is uploaded and the subsequent images are created (all the different sizes), I would like to perform a few actions. It is simple and I basically need only the new attachment ID, that would be enough.

Same during deletion: before or after deletion, I need to know which attachment ID is concerned.

Thanks for your help :)

1 Answer 1

8

i guess you are looking for this

add_attachment

and

delete_attachment

example:

add_action('add_attachment', 'attachment_manipulation');
function attachment_manipulation($id)
{
  if(wp_attachment_is_image($id)){
    //do your own tasks
  }

}
1
  • and don't forget edit_attachment (in case you care if the image is rotated or scaled after being added)
    – DavidJ
    Commented Sep 3, 2012 at 17:38

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.