wp-cli / media-command

Imports files as attachments, regenerates thumbnails, or lists registered image sizes.
MIT License
44 stars 41 forks source link

skip existing and delete unregistred in WP cli ? #111

Closed Mag8891 closed 5 months ago

Mag8891 commented 5 years ago

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

Beee4life commented 5 years ago

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.

kkmuffme commented 4 years ago

@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.

Beee4life commented 4 years ago

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)

kkmuffme commented 4 years ago

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

Beee4life commented 4 years ago

sorry my bad, overlooked it.

dademaru commented 3 years ago

-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.