Sign in to follow this  
Followers 0
-Musafir-

Delete Mass Media Images from Wordpress

1 post in this topic

Delete thousands of images from wordpress media library

 

I have a workaround for this... it's a bit messy, but it works. You need to have phpMyAdmin access for the database. And obviously all the usual "OMG, don't do that" warnings apply - take backups, don't blame me if it fails, etc. :)

I just got rid of over 200,000 unattached media items on one of my blogs by this method.

 

1. Install the DX Delete Attached Media plugin (http://wordpress.org/plugins/dx-delete-attached-media/)

 

2. Create a new post. I named mine "Unattached media" and saved it as draft.

 

3. Find the post number. Just go to the posts list, click the post title and look at the URL: it will have "post=xxxxx" in it.

3. Run the SQL in your phpMyAdmin interface:

UPDATE wp_posts
SET post_parent = 'post number'
WHERE post_type =  'attachment'
AND post_parent = '0';

4. Go back to your posts list and send your post to the trash.

 

5. Make sure the DX plugin is activated, empty trash. Bingo, all dead items gone.

 

Note that if there are a LOT of items, you might have to just leave the post in the trash and wait for WP's standard trash emptying procedures to handle it. But it still works.

 

Hope it helps!

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0