开发者 | Iulia Cazan |
---|---|
更新时间 | 2023年11月15日 03:09 |
PHP版本: | 7.0 及以上 |
WordPress版本: | 6.4.1 |
版权网址: | 版权信息 |
Image Regenerate & Select Crop
to the /wp-content/plugins/
directory of your applicationThe list of wp-cli commands available with this plugin can be checked by running this command in your terminal:
wp sirsc --help
. This will show you a list of the available subcommands and their current description in terms of purpose, arguments types, and order:
cleanup
-- arguments order and types: (int)site_id (string)post_type (string)size_name (int)parent_id
-- the command targets images based on the relations with the specified post type, perhaps a parent, and performs the sub-sizes cleanup for all or the specified sub-sizes (delimited with a comma)rawcleanup
-- arguments order and types: (int)site_id (string)post_type (int)parent_id
-- the command targets images based on the relations with the specified post type and perhaps a parent and performs the raw cleanup for all the files, except for the full/original sub-sizeregenerate
-- arguments order and types: (int)site_id (string)post_type (string)size_name (int)parent_id
-- the command targets images based on the relations with the specified post type and perhaps a parent and performs the sub-sizes regeneration for all or the specified sub-sizes (delimited with a comma)resetcleanup
-- arguments order and types: (int)site_id (string)post_type (int)parent_id
-- the command targets images based on the relations with the specified post type and perhaps a parent, and performs the reset cleanup for all the sub-sizes, keeping the full/original + only the registered image sizes at the moment when the command runs--verbose
- this attempts to give a detailed description of the execution--force
- available for the cleanup commandTo clean up all the sub-sizes for all the images in the project you can run a command like this: wp sirsc cleanup 1 all all 0
.
– 1 = specifies the site/blog id in a multisite (set it to 1 in a single site install)
– all = the post type (set it to all if you want the execution to happen for all post types)
– all = the sub-size (set it to all if you want the execution to happen for all registered sub-sizes)
– 0 = attachment parent id (leave it to 0 if you want to execute for all of the attachments, not just for the attachments of a specific post)
If instead, you want to clean up only the medium sub-size, and let's say only for the pages, the command can be used like this: wp sirsc cleanup 1 page medium 0
.
As you can see, depending on what you are aiming to clean up, you can combine the arguments.
If you are using the --force
flag for the command, the targeted sub-size will be used for cleanup, even if it is not registered in the project anymore (left behind in the project by other themes or plugins that are no longer used).
To clean up all the sub-sizes for all the images in the project and start again with keeping only the full/original attachment file, you can run a command like this: wp sirsc rawcleanup 1 all 0
.
– 1 = specifies the site/blog id in a multisite (set it to 1 in a single site install)
– all = the post type (set it to all if you want the execution to happen for all post types)
– 0 = attachment parent id (leave it to 0 if you want to execute for all of the attachments, not just for the attachments of a specific post)
To clean up all the files and metadata for sub-sizes that are no longer registered on your site, you can run a command like this: wp sirsc resetcleanup 1 all 0
.
– 1 = specifies the site/blog id in a multisite (set it to 1 in a single site install)
– all = the post type (set it to all if you want the execution to happen for all post types)
– 0 = attachment parent id (leave it to 0 if you want to execute for all of the attachments, not just for the attachments of a specific post)
To regenerate all the sub-sizes for all the images in the project you can run a command like this: wp sirsc regenerate 1 all all 0
.
– 1 = specifies the site/blog id in a multisite (set it to 1 in a single site install)
– all = the post type (set it to all if you want the execution to happen for all post types)
– all = the sub-size (set it to all if you want the execution to happen for all registered sub-sizes)
– 0 = attachment parent id (leave it to 0 if you want to execute for all of the attachments, not just for the attachments of a specific post)
If instead, you want to regenerate only the medium sub-size, and let's say only for the posts, the command can be used like this: wp sirsc regenerate 1 post medium 0
.
add_filter( 'sirsc_bypass_logs', '__return_true' );
in your codesirsc_keep_scaled
, which allows preserving the scaled versionthumbnail
vs shop_thumbnail
).resetcleanup
& rawcleanup
). USE THESE AT YOUR OWN RISK.