From a quick look there is a dedicated delete_attachment
action in wp_delete_attachment()
function, it gets passed an ID of attachment being deleted.
However I am not completely confident that this covers all cases. There is a fair amount of duplication in WP’s post–related APIs and similar tasks might be performed by different functions in different places.
I would start with this hook and experimentally check if it’s sufficient for desired scenarios.
Related Posts:
- Get All Images in Media Gallery?
- How to add subfolders in media library for better organisation?
- How to display .ico files in the media library
- List of available events for wp.media
- Uploading Images to Media Library via wp_handle_sideload() fails
- Bind event on Media gallery elements WordPress
- Add class=”media_type” when media is inserted into editor
- How can I list URLs of all audio files within my media gallery?
- Migrating to HTTPS only, most media library links need updating?
- Failing to open advanced-cache.php which is breaking Media Library
- Filter pictures in the media library [closed]
- How to save attachment data?
- How to enlarge thickbox media library iframe?
- How to modify Media Library images
- WordPress 3.5 Media Manager – Reorder Selectbox items on Media Library Tab [duplicate]
- Inserting a Download Link in the Quick Edit Actions of the Media Library?
- How do I remove the entire Media section from the main WordPress navigation without just hiding it?
- Is there any way to add images to the Media Library through a path on the server?
- Media Library page super slow, loading up full quality images
- Share media among different domains
- Where is the source of the media items filter
- Bulk Import files on Media Library from CSV
- Media gallery thumbnails 1px
- “Insert Into Post” For Custom Button
- How to have changes made in media library to be reflected on posts/pages
- Display image file size in media library
- Media_handle_upload with custom upload folder?
- Remove the ‘Attachment Details’ section of the wordpress media manager
- remove_menu_page breaks “Add media”
- Featured images get shrunken
- Organize media uploads in folders – I have a physical access to (my) server
- Pulling images from a subdomain
- Get image URL from media library “insert from url”
- Sorting Media Library by Author Name
- Media gallery: remove “insert into post” button keeping “Insert gallery” button
- Media Library not showing images properly
- Media Content disapeared after upgrade WP core to 3.5.1
- The best way to protect uploaded media in WordPress?
- change video icons to selected thumbnail?
- Media Library Grid View Custom Filter
- how to remove thumbnail and LiteSpeed Optimization column in media library list-view?
- Not able to extend wp.media.view.AttachmentsBrowser
- Custom Media Modal and uploading
- Media Library No Longer Displays Images
- Media Library SSL
- Change Media Library thumbnails for non-image files to include the post title instead of the filename?
- attachment media-template data model (data.size.url)
- Media library and posts list problems with WordPress on IIS
- How do you alter the default WordPress thumbnail?
- Media Library, hook on delete user action
- “add from media library” tab is super slow [closed]
- Create a User Role with permissions to only upload files to the media library?
- Reorder attachements in the media library
- Adding Alt Tag Column to Media Library List
- High CPU load when loading images in media library
- How to modify the attachment info text on gallery tab or media page?
- Add media button always inserts media on the next wp_editor instance when created dynamically
- Adding Alt Tag and Dimensions columns to Media Library
- Media Library Latency, Lag, CRON?
- Is it Helpful to transfer all media library to another host? [closed]
- Media library on another server?
- Is there a way to determine if the media-iframe is visible?
- What would be the URL to display the WordPress image editor with an image from the media library?
- Prevent other editors from viewing images of other editors in Add Media Popup
- Media attachment date and post date
- Windows Live Writer inconsistent with Media Library
- Is there a way to programmatically pass a category to the Media Library selector?
- User media folder for each users on registration
- Larger preview thumbnails in Media Library
- How can I no-index specific PDF files in my Avada WordPress media library so that they don’t appear in search results?
- Media Library http to https
- Filter media library by custom postmeta
- How do you find a file in the media library using the file URL?
- How to limit the amount of images uploaded to the media library within post.php
- Adding Facebook Open Graph Code does not work for Media Library Attachment Pages
- Media library corrupted after upgrading to 4.9.6
- query that alternates text posts with images from media gallery
- Can multiple sites under one folder structure share media directories?
- WordPress not using edited image
- How to display the date a directory folder on ftp was modified
- When I’m in post editor and click on ‘Add media’, why won’t it load the media library with this code?
- Create gallery doesn’t show uploaded images
- Media Library not showing images when adding to Posts (but retrieving image info via ajax)
- WordPress 3.5 Media Manager – Change loaded image Size [duplicate]
- How use Videos from another directory?
- Remove (Unattached) Attach from “Uploaded to” in Media Library
- Uploading pictures to the Media Library: “Specified file failed upload test.”
- Use the “Media Library” in Frontend
- Why is my upload / Select media library button empty?
- WordPress Media Library
- Create media library feed
- Broken image links in media library after restore
- Store images and videos category wise and fetch them in json format
- Add Filename Colum to Media Library
- create a user’s owned folder on user registration
- 2 or more WordPress instances (Live vs Staging Test site) –> access 1 uploads.domain.com — images holder – see images in Media Library
- media library contains corrupt doubles
- How can I change the page title of PDFs opened from a WordPress link which use the browser’s viewer?
- Files showing in link but cannot be found in the upload directory
- Block non logged in users from accessing the media library