• Resolved Sean

    (@sean-h)


    So we are busy with a major tidy up of our now 10 year old blog (in staging). Apart from basic update maintenance, we haven’t updated any content in years, so much so we hadn’t noticed there are now up to 8 copies of a single image in the WP Media library, but mostly 4 identical copies of 1. Identical, in that they are all the same size, same title, same alt text, .jpg all that. So which one of the copies do we delete? Even these tidy up plugins don’t know which one to delete and end up deleting an image still in use.

    Last time we checked the media library it had about 1200 images. It now has 6995, and we know we didn’t put them all there.

    This poor site has been moved around quite a bit in the last 10 years, even before it got to Siteground, then it got moved from SingleHop to Google Cloud, cPanel to SiteTools. I have also tried a few different optimising plugins over the years, W3TC included. Now using just Speed Optimizer. At least if we can rule out what could not have caused this I can spend more time looking at what might have caused this.

    I guess this is one problem with leaving a site unattended for too long. You end up forgetting exactly what you did and when you did it, which makes troubleshooting things like this a bit of a challenge.

    One theory I have is while experimenting with SG Optimizer as it was when I first used it I might have checked the box that made back up copies of all images when changing compression levels. I might have done this more than once. Also switching webp on and off, along with cron jobs not working properly at one point. Cron is now working fine.

    It’s beginning to look like the only way to clean this mess up is by manually going through the entire library, 1 image at a time, then checking each of the 76 posts to verify if any images go missing. My wife and I, each with 2 screens could get it done in a day.

    As mentioned, I have tried 2 plugins, Media Deduper and Media Cleaner. No joy. They either delete the wrong image, or miss the ‘copies’.

    Looking in the File Manager I can see the various images sizes that WP makes on upload as well as the webp versions created by Speed Optimizer. I’m still trying to figure out if there are in fact copies in the files as seen in the media library.

    Another theory I have is the database is maybe referencing the same image multiple times, which then shows as multiple copies of the same image in the WP media library. Is that even possible?

    But my main theory is multiple backups of images made by the Speed Optimizer when playing with compression levels, and cron not working properly and the process subsequently failing, or something to that effect.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support daniellaivanova

    (@daniellaivanova)

    Hello @sean-h,

    Given the complexity of the situation, a combination of manual review and technical intervention seems necessary.

    What I can suggest is the following course of action:

    • Create a full backup of your website, including all files and the database
    • Before deleting any files, check that the images are not used in posts, pages, or as theme elements
    • Carefully delete the duplicate files, ensuring you keep at least one copy of each image that is still in use
    • After deletion, browse your website to ensure no images are missing from posts or pages

    Remember to proceed with caution and consider working on a staging environment when testing cleanup methods.

    Best Regards,
    Daniela Ivanova

    Thread Starter Sean

    (@sean-h)

    Hi @daniellaivanova,

    I’m pretty much doing just what you suggested, manually deleting one by one, in staging. I was in staging already because of the re-design. I will only push the staging live when I’m 100% certain nothing is missing as all images are still in the live site. I can always retrieve anything from the live, if necessary.

    What I noticed is there is no trash for media by default. This you have to manually enable in wp-config. Something I’d like the writers of WordPress to explain.

    A tedious job, but it must be done. 2 screens helps, a lot. And even then, I’d still be very curious as to what happened and how to prevent this in the future. Luckily this has only happened on 1 of the 6 sites I manage. You don’t think SG Optimizer had anything to do with it? Don’t worry, I’m not holding anyone responsible ??

    Moral of the story, I don’t think any plugin or AI will ever be able to do what I’m busy doing right now, so it’s good to know I still have a job.

    Plugin Support daniellaivanova

    (@daniellaivanova)

    Indeed, WordPress does not enable a trash system for media files by default. The decision not to include a trash system for media files might be due to the potential for large media files to consume significant server space even when they are no longer needed on the site.

    To enable the trash system for media files, you can add the following line to your wp-config.php file:

    define('MEDIA_TRASH', true);

    This will allow you to restore or permanently delete media files from the trash, similar to how posts and pages are handled.

    Regarding the SG Optimizer plugin, it’s a tool designed to improve the performance of WordPress sites by optimizing various aspects of the website. While it’s not common, it’s possible that optimization processes could lead to unexpected behavior, especially if there are compatibility issues with other plugins or themes, or if certain settings are misconfigured. However, at this point, it is hard to specify which plugin caused the issue you’re experiencing.

    Best Regards,
    Daniela Ivanova

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Up to 8 copies of a single image’ is closed to new replies.