Remove Unused Images From Media Library

Support General Remove Unused Images From Media LibraryResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26515
    JasonJason
    Participant

    I have several unused images in my media library. So, it's not very efficient to delete them from the media library one by one. I'm using this plugin to remove the orphaned image in my media library. But it doesn't detect the images that are used by Metabox. So, it incorrectly deletes those images.
    https://meowapps.com/plugin/media-cleaner/

    Do you have a solution for bulk deleting unused images, that will not delete the images used by the metabox plugin?

    #26532
    Long NguyenLong Nguyen
    Moderator

    Hi Jason,

    Each image is a post (post type attachment). So you can delete images by using the function wp_delete_attachment() in the loop and check a condition if the post has meta (field) value https://developer.wordpress.org/reference/functions/get_post_meta/.

    #26582
    JasonJason
    Participant

    Thank you for your help. Also, I found this plugin that automatically deletes attachments when a post is deleted. I'm having success with this plugin.
    https://wordpress.org/plugins/autoremove-attachments/

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.