WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :)

share|improve this question
up vote 7 down vote accepted

i guess you are looking for this





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

share|improve this answer
Thanks it helped :) – TigrouMeow Jun 25 '12 at 9:50
and don't forget edit_attachment (in case you care if the image is rotated or scaled after being added) – DavidJ Sep 3 '12 at 17:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.