Best way to clean up Media Library? 1,500 images, only a couple hundred actually being used.

[ad_1]

Is there any way of seeing a list of media that are actively being used on a Published and/or Draft page?

What is the most efficient method of cleaning up a Media Library with about 1,500 images, knowing that the majority of them aren’t being used?

[ad_2]
4 Comments
  1. Maybe with a query. wp_posts where media is referenced. Then just sort against whole media List. Not sure.

  2. There are several plugins available that can help you identify and clean up unused media files in WordPress. One such plugin is “Media Cleaner.” Here’s how you can use it:
    Install and activate the “Media Cleaner” plugin from the WordPress plugin repository.
    Go to “Media” → “Media Cleaner” in your WordPress dashboard.
    Follow the on-screen instructions to analyze your Media Library for unused files.
    The plugin will scan your Media Library and identify unused files, allowing you to review and delete them. Or you can run a SQL query like this:
    SELECT * FROM wp_posts WHERE (post_content LIKE ‘%image-filename.jpg%’); But the last one is kinda risky, I would recommend using plugins

  3. I’ve often wondered about this but I’m not sure there’s an adequate solution. You can see which images are attached to a post or page (or what not) but that doesn’t necessarily tell you if the image is being used. Or confirm that an image *isn’t* being used.

    For example you could upload a logo thru Media and then paste the URL into your theme settings. That image isn’t attached to anything but it’s in use.

    Or you could upload an image thru the classic editor and then remove it from your content. It will be attached but not in use.

    I think you’d have to write a fairly complex script to search the posts, post meta and options tables (as well as any other plugin related tables) to see if they reference the file names of any of the variations of each media item. But you’d also have to analyze the structure of the tables and and see if any of them reference the IDs of media.

    That said, I’m very curious if you find a solution.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer