• DemInPractice

    (@deminpractice)


    Hey y’all,

    Could not find these questions asked elsewhere…

    I’ve tried using several ‘media cleanup’ plugins but I find them rather glitchy (must be why they are not very popular/highly rated). After 2 years of extensive visual trial and error, our wp-content ‘uploads’ folder contains over 4,000 images and weighs in at 538Mb. I compiled an optimized version of every image currently in use on our site and it only totals 90 and weighs only 7Mb.

    So, (I have a backup) I would like to completely WIPE MY ‘UPLOADS’ FOLDER CLEAN and start fresh uploading those 90 current images using the media uploader within WordPress and I can manually update urls in my html. NOTE: I DON’T WANT TO RESET ANYTHING ELSE – ALL PLUGINS, PAGES, CSS, ETC. NEED TO STAY UNTOUCHED. But I wanted to ask a few questions first to make sure I don’t really screw something up:

    If I’ve got the ‘uploads’ folder backed up, is there any important reason why I shouldn’t do this? (I’m surprised I couldn’t find anyone on the web explaining how to do this)

    What is the best way to completely empty the wp-content ‘uploads’ folder? (I was planning to use Filezilla to overwrite it with an empty ‘uploads’ folder, but will wordpress automatically generate necessary sub-folders?)

    What do I need to do to update WordPress’s database so that no part of my site thinks that those images are still there and everything with respect to media registers as empty?

    I’d also like to change the location of the ‘uploads’ folder to a subdomain via the ‘wp-config.php’ file (I read that it will speed up page loads), and I’d prefer to have uploads NOT organized by years and months (although that option is not showing). In-and-amongst emptying the ‘uploads’ folder, when should I move it and change the way it is organized?

    Many thanks!
    Adam

Viewing 3 replies - 1 through 3 (of 3 total)
  • leejosepho

    (@leejosepho)

    There are two ways to do what you want to do:

    1a. Export all content (pages & posts) and users from the Dashboard;
    1b. Make a new (wp-config) table_prefix for the database;
    1c. Import all content (pages & posts) and users at the Dashboard;
    1d. Reset your various theme, menus, widgets and other Dashboard settings;
    1e. Jump to 2b.

    2a. Delete all media directly from/at the Media Library;
    2b. FTP-upload the new media;
    2c. Use ‘Add From Server’ (plugin) to register same in database (using “Current Time” and not “File Time”);
    2d. Attach new media to respective pages and posts;
    2e. Fix links as you have already mentioned.

    note: As best I can recall at the moment, I believe ‘Add From Server’ will leave your uploads folder or folders as it finds them, and then WordPress will do the same from then on as long as the “monthly” box remains unchecked.

    Thread Starter DemInPractice

    (@deminpractice)

    Thanks for the reply leejosepho! That first route worries me a bit that maybe my Page Builder Templates might get forgotten, or something else that I’ve jimmy-rigged into place.

    I found this suggestion online to run these queries in phpMyAdmin to delete all media in the library, and remove all post attachment affiliation:

    # First:
    
        DELETE FROM wp_postmeta
        WHERE post_id IN
        (
        SELECT id
        FROM wp_posts
        WHERE post_type = 'attachment'
        )
        ;
    
        # Second:
    
        DELETE FROM wp_posts WHERE post_type = 'attachment'

    Would that work as well? Any drawbacks of that approach?

    Thanks,

    Adam

    leejosepho

    (@leejosepho)

    …queries in phpMyAdmin to delete all media in the library, and remove all post attachment affiliation…

    Would that work as well? Any drawbacks of that approach?

    None that I know about, but I cannot speak for that actual code! So, first make a complete database backup “just in case” and give it a try.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I completely erase all uploaded media?’ is closed to new replies.