• I’m looking for a way to bulk remove files too large for my website. In the past all kinds of sizes were uploaded, when I took over I put up a maximum of 1200x1200px, but a lot of images still have their old sizes. I had hoped the following command would clean those up, but when I run it the files larger than the set dimensions remain.

    wp media regenerate 408339 --delete-unknown

    I have also added this to my theme: add_image_size( 'maximale_grootte_afbeelding', 1200, 1200 );

    Help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator threadi

    (@threadi)

    According to the manual, the WP CLI command should be sufficient: https://developer.wordpress.org/cli/commands/media/regenerate/

    My guess is that the images aren’t being removed because they’re still being requested by some component of your project. For example, use https://wordpress.org/plugins/regenerate-thumbnails/ to see which image sizes are even recognized in your project. All recognized sizes must also exist as actual images. If you want to do away with certain image sizes, you may need to disable them first. This can often be done at the source that defines the image size in the project (theme or a plugin).

    Thread Starter vespino

    (@vespino)

    That plugin triggered something.. I also have to remove a few larger images sizes that seem to be in place by default:

    remove_image_size( ‘1536×1536’ );
    remove_image_size( ‘2048×2048’ );

    Haven’t tested via CLI yet, but the plugin did work, so I’ll do some testing there next.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.