10 Comments

  1. John
    · Reply

    There is also another 100% free alternative that I always use and that works really fine – Find Posts Using Attachments:
    https://wordpress.org/plugins/find-posts-using-attachment/

    Report

  2. calm
    · Reply

    This is a problem that needs to be solved in core, but it is nice to see that there are plugins trying to solve it. Still, searching the DB, which is most likely what the plugin does, is an incomplete solution like your [gallery] example shows.

    What is realy needed is to search usage in the generated HTML, this will help compatibility with more plugins, especially those that store the attachment ID instead of the URL. It still not going to be enough for attachments used on admin side.
    Maybe it should use the webserver log as a real life indication for what is used.

    But the real question is, what is the use case, and since it is a paid plugin, what is its ROI? storage is cheap and the amount of work that will go into verifying the images most likely will cost more than the extra cost of the storage.
    Maybe the “find where an image is used” part is worthy even if can’t be 100% complete, the “remove” part probably pointless.

    Report

    • Jonas Tietgen
      · Reply

      Hey calm,

      You are right, this is a problem that should be solved in core. However, solving it in core will only work if every plugin adheres to the standards defined by the core. As this is highly unlikely to say the least, there will always be heaps of plugins that use attachments that would not be detected by such a core feature. This is where Remove Unused Media shines, as it does not rely on any standard way of including attachments. Unlike your assumption, it does not just search the database but checks the generated HTML as well. It checks portions of the database, the generated HTML as well as some special locations to find as many media usages as possible without false positives or taking hours. An actual real time solution is in the works.
      Checking the webserver log does not work in many cases. Imagine a post that is rarely viewed, the included media files would be marked unused and get deleted.

      Storage is cheap, but speed and time are invaluable. A cluttered website reduces productivity and speed. True, for most people the ROI of Remove Unused Media is not measurable, but once a site reaches a certain size cleaning up becomes a necessity, and this plugin saves you a lot of time and makes it much easier and less error-prone to do a real clean-up.

      Greetings from the Remove Unused Media team,
      Jonas

      Report

      • Robert Trevellyan
        · Reply

        I can think of two real issues with a bloated media library:
        1. When browsing the library, the more items there are, the harder it is to find what you’re looking for.
        2. When backing up a site, either routinely or as part of a migration, media files take up the most space and therefore the most time.

        Report

        • calm
          · Reply

          @robert
          If you have so many unused images in your media library to have an actual performance impact you should ask yourself how did you get there.

          I would assume that most people do not upload images “just because”.

          @junas
          As I said I don’t think the plugin is useless, just that you emphesize the wrong functionality.

          The internet is interconnected and just because a image is not used on the site do not mean it is not used on other sites. Maybe you host it on one of your sites while using it on another. Maybe you use it in some public API integration (opengraph comes to mind, but also newsletters authored outside of the site are good candidates), so does anyone can be 100% sure that deleting an image has no impact? This is where the plugin needs to show its ROI as the effort in making sure an attachment can actually be deleted might not be trivial at all.

          The original problem here is that all attachments are public once they are uploaded and therefor you do not have an “not published” state for attachments that you could have used as signal that it is truly not used.

          Report

          • Robert Trevellyan
            · Reply

            We typically see this with WooCommerce stores. Site owners rarely go back and delete images of deleted products. It adds up fast for stores with a high rate of change of catalog.

            Report

            • calm
              · Reply

              @robert, agree but for me it sounds like a call to a WC specific plugin (or a more genric one for when posts of any type are deleted) but it probably should happen when the post is deleted and things are still fresh in the memory of the admin, not 6 months later when it is hard to remember what was used where.

              Another posibility is to limit attachment usage to specific content and than automatically remove them when the content is deleted, but this is almost for sure something that require support in core.

              Report

  3. Miroslav Glavić
    · Reply

    This feels like it should be a core function.

    One of the sites I manage, has a weather page.

    (flag) (country name), click on the country name and it takes you to a list of cities.

    If Canada, it goes to a list of provinces/territories. If US then US States, if Croatia then counties.

    After you click on the Canadian provinces/territories, US States, Croatian counties and so forth, you get the cities.

    When in the middle list you get to see (country flag)(province/territory/state/county/etc flag), then when you get to the municipal lists you see (country flag)(province/territory/state/county/etc flag)(municipal flag) (city/town/village name) (weather icon/temperature).

    190-200 countries, Canada has 10 provinces and 3 territories, US has 50 states plus it’s dependencies/territories (like Puerto Rico and so forth), Croatia has 20 something counties. Other countries have 10+ provinces/states/departments/territories. Thousands of municipal flags.

    I think I have over 1,000 flag icons. Countless photos for articles (not just in weather content)….I had this specific site since 2000. 21 years adds up thousands of thousands of photos and graphics.

    I had to delete a few articles from time to time. I can’t remember the last time I cleaned up my media. I should but it is difficult to go through 50,000+ media files, I am sure it is closer to 85,000+.

    This should be part of core. Every 5 years I could do media cleanup.

    Report

  4. Ben Byrne
    · Reply

    Another alternative to consider is Media Deduper Pro, which can similarly identify unused media, as well as flag duplicate files and also identify images in the media library that don’t have default ALT values set.

    Don’t blame you for not mentioning it here since its “main” functionality is eliminating duplicate media files, but it definitely also addresses this need. (I can provide a free license if you want to check it out.)

    Report

  5. Brian O'Neill
    · Reply

    I find the biggest problem is WordPress generating unneeded image sizes. One uploaded image can have 6 different size files. Does it delete unused image sizes?

    Report

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: