WP Manifestindependent plugin directory
manifest / media / delete-attachments

Delete Attachments GitLab

by Filip Van Reeth · gitlab.com/filipvanreeth/delete-attachments

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://gitlab.com/filipvanreeth/delete-attachments/-/archive/main/delete-attachments-main.zip

Delete Attachments WordPress Plugin

This plugin allows you to delete files attached to a post or page from the media library.

Filters

You can use the delete_attachments/delete to add your own functionality when an attachment is deleted.

The filter has two parameters:

  • $attachments - An array of attachment IDs to be deleted
  • $posts - An array of post IDs that the attachments are attached to

Example

function my_delete_attachment_function($attachments, $posts) {
    // Do your stuff.
    return $attachments;
}

add_filter('delete_attachments/delete', 'my_delete_attachment_function', 10, 2);