media-command icon indicating copy to clipboard operation
media-command copied to clipboard

skip existing and delete unregistred in WP cli ?

Open Mag8891 opened this issue 6 years ago • 6 comments

Hi is there a way to set up below commands with WP cli as well or is it set by default? I couldn't find it anywhere.

-Skip regenerating existing correctly sized thumbnails (faster). -Delete thumbnail files for old unregistered sizes in order to free up server space. This may result in broken images in your posts and pages.

Many thanks

Mag8891 avatar Jun 11 '19 14:06 Mag8891

You mean these commands ?

I can't get the --skip-delete function to remove old images though... I am not the only one I saw who reported it... See this topic.

Beee4life avatar Sep 22 '19 10:09 Beee4life

@Beee4life no this is something completely different e.g. for a test environment I want to import pictures with a script, but some pictures may already exist in the db from previous test versions. In these cases I want to skip importing images that already exist.

Regeneration command is only for images that already exist.

kkmuffme avatar Apr 26 '20 10:04 kkmuffme

Then your original post is incorrect. You ask if it's possible to : "Skip regenerating existing correctly sized thumbnails" So yes, that is possible, with the --only-missing parameter.

I think you need to undertake 2 actions: 1 import the images 2 regenerate (with --only-missing)

Beee4life avatar Apr 26 '20 13:04 Beee4life

I'm not the OP, just having the 2nd issue too. But I guess I'll create a new card for my specific one

kkmuffme avatar Apr 26 '20 19:04 kkmuffme

sorry my bad, overlooked it.

Beee4life avatar Apr 27 '20 11:04 Beee4life

-Skip regenerating existing correctly sized thumbnails (faster). -Delete thumbnail files for old unregistered sizes in order to free up server space. This may result in broken images in your posts and pages.

These are options of Regenerate Thumbnails plugin. However, the author of the plugin recommends:

If you have command-line access to your site's server, consider using WP-CLI instead of this tool. It has a built-in regenerate command that works similarly to this tool but should be significantly faster since it has the advantage of being a command-line tool.

Unfortunately, WP-CLI doesn't have the second option.

It would be ideal if it could be added.

Meanwhile, an alternative with command line is to use the rm command with some RegEx to delete specific sizes.

dademaru avatar Sep 09 '21 08:09 dademaru