Our WordPress site has thousands of images and most of them are not used for any content anyomore.

The images take about 90% of our total storage so I wanted to get rid of them. I used a plugin called cleaner that was claimed to delete unused images from WordPress. The plugin deleted the unused images but also deleted some of the images that were used in gallery. Somehow those images were registered as not used so the plugin deleted them.

Now I cannot see any of the images in the gallery. The whole gallery is empty and I cannot add the images back to the system because WordPress won't recognize them since they've been removed from the database.

Thankfully I had made backups of the files and also the database. So I copied the image back to the original places without overwriting the existing images.

The WordPress wasn't showing the images on the media manager and also the gallery was still empty. So I went and restored just the wp_postmeta table from the backup database. The gallery still won't show any images and I cannot find any deleted images on the media manager.

I was suggested the wp_postmeta stored the media files' information. I could restore the whole database but the website has been updated with new content and going back is not a choice.

Is it possible to revert back the images if I have the old database and old images intact? So that the gallery would show images and the new content stayed intact?

2 Answers 2


In this case, I would setup a dev environment using the old backup, restore the new content from the live site and then push the development site to production.

p.s you should never work in a live/production environment, just clone your WordPress to test new plugins.

  • I think that is a very good solution. I would still like to see if there are other solutions. :)
    – Arpan
    Sep 15, 2017 at 1:46

To restore the links to the images so that they show up in Media gallery, you will have to restore not only the wp_postmeta table but also wp_posts table from your backup. However, you would loose any posts done after your backup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.