• I was trying to clean up my media library. Whether it’s done using a plugin or manually, it seems people say to delete “unattached” media. However, I’ve found that “unattached” doesn’t mean “not used.” My site isn’t currently live so I don’t have a URL, but I do have a screen shot: https://goo.gl/HjpTwh

    You’ll see I’ve labeled images “1,” “2,” and “3.” Each of these are “unattached,” but each is being used.

    #1 – Being used by widget in the footer
    #2 – Being used by the theme for the front page hero area
    #3 – Being used by a “coming soon” plugin

    Now, here’s my concern. If I simply delete all media that is “unattached,” then even media being used will be deleted. However, I’m not exactly sure which of the “unattached” media are being used. When I try attaching the media, it wants to know to which post or page it’s to be attached. However, the answer is “none.”

    Is there a way to tell which media are being used, not just “unattached”?

    • This topic was modified 7 years, 5 months ago by jrothra.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Media is only attached to a page or post when it is uploaded from the edit screen for that particular post or page. Adding to the media library from the Media section of the admin won’t attach it to the page. Media could (although I’m not 100% on this) become unattached if the page or post it was uploaded to no longer exists.

    This means that whether media is attached or not is not a reliable way to know if the media is used, as you’ve discovered. Unfortunately this is the only time WordPress ever makes a database record of when media might have been used. The only other way to tell would be to scan post content for image URLs and compare them against the media library.

    Thankfully some plugins exist to do this for you. I’ve found https://www.ads-software.com/plugins/media-cleaner/ and a paid plugin: https://www.nicearma.com/delete-not-used-image-wordpress-dnui/ I haven’t used either myself, so couldn’t comment on their quality.

    One thing I would be careful of is whether these plugins handle custom fields, widgets, or custom tables added by plugins, because images could be in use that aren’t in post content, but are somewhere else. Keep that in mind when evaluating these plugins.

    • This reply was modified 7 years, 5 months ago by Jacob Peattie.

    Yeah, the plug in’s run off the same query for unattached files and because of that, delete many files that are incorrectly reported as being ‘unattached’, so, the idea that these plug in will fix this issue is incorrect.

    I have the same issue. WC/WP seems to manufacture all manner of duplicates for the single photo file I upload into product posts. In and of itself, this is not an issue as much as being told a file is ‘unattached” and when I delete it permanently, I lose the product photo file.

    I want to improve performance of my site. How do I search for legitimately unused photo files to delete?

    one more item, I don’t want to sit here for hours doing it one by one as many have suggested I waste time doing. There has GOT to be a better way.

    rngeer

    (@rngeer)

    I am looking for something similar.

    I recently moved a site to a new server and used the plugin Add From Server for the media library. It worked great but now I have a ton of images that show unattached.

    Is there is a bulk way to search and reattach images so I can clean up the library from excess images that aren’t being used?

    I hope this makes sense.

    Bump!

    Would love to see a resolution to @jrothra’s issue, I would say this is a valid concern and a fix would make WP a more robust CMS.

    Jay

    (@darthdocgmailcom)

    I’d also like to see a better way to reliably do this without deleting images that are actually used on the site. I’d also like to see folders in the Media section if we’re putting wants out there. LOL

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Media Library says Image “Unattached” but It Is Used’ is closed to new replies.