Disable deletion of attachments

When posts are pruned they delete the featured image and any attached media. Can we disable that in the plugin? Sometimes we have common media across several posts and it still deletes, leaving 404s behind.

2 thoughts on “Disable deletion of attachments

  1. the support admin

    Hi Joe,

    the current code will indeed remove the attachments that were uploaded on the current (deleted) post.

    Thanks for your suggestion.
    If you are in need to this to NOT delete attachments, edit the auto-prune-posts.php like so:
    OPEN
    auto-prune-posts.php

    FIND
    if ($atts) {
    foreach ($atts as $att) {
    // Deletes this attachment
    wp_delete_attachment($att->ID, $force_delete);
    }
    }

    REPLACE WITH
    if ( false && $atts ) {
    foreach ($atts as $att) {
    // Deletes this attachment
    wp_delete_attachment($att->ID, $force_delete);
    }
    }

    Reply

Leave a Reply to the support admin Cancel reply

Your email address will not be published. Required fields are marked *