I need to run my function when a user deletes a media file from the media library. Is there a hook I can use?
Would appreciate it if someone could please point me to the right direction.
Thanks!
I need to run my function when a user deletes a media file from the media library. Is there a hook I can use?
Would appreciate it if someone could please point me to the right direction.
Thanks!
You must be logged in to post a comment.
A more appropriate hook may be
delete_attachment($post_id)
. You may also need to hookedit_attachment
. Note that thepost_id
is that of the attachment type post, not the page/blog post to which the media is attached (if any).In case you want to know when media is added, hook
add_attachment($post_id)
. Note thatadd_attachment
is called before intermediate size files are generated but after the media has been placed in the upload directory.