What does it do?
The plugin appends two custom buttons that allow you to regenerate or crop the images. Additionally, it provides details about the image sizes registered in the application and the status of each image size for images. The plugin also appends a sub-menu to “Settings” that allows you to configure the plugin for global or particular post type attached images and to enable the developer mode for debugging if necessary.
You can download the free plugin from the WordPress repository. If you would like to support my work, please leave a 5 stars rating, or share this plugin on your feed.
A huge thanks in advance!
The “Details/Options” button will open a lightbox where you can see all the image sizes registered in the application and details about the status of each image size for that image. If one of the image sizes has not been found, you will see more details about this and, if possible, the option to manually generate this (for example the image size width and height are compatible with the original image). For the image sizes that are of the “crop” type, you will be able to re-crop in one click the image using a specific portion of the original image: left/top, center/top, right/top, left/center, center/center, right/center, left/bottom, center/bottom, right/bottom. The preview of the result is shown right away, so you can re-crop if necessary.
The “Regenerate” button allows you to regenerate in one click all the image sizes for that specific image. This is really useful when during development you registered various image sizes and the already uploaded images are “left behind”.
The plugin does not require any additional code, it hooks in the admin_post_thumbnail_html and edit_form_top filter and appends two custom buttons that will be shown on the “Edit Media” page and in the “Edit Post” and “Edit Page” where there is a featured image. This works also for custom post types. Also, it can be used in different resolutions and responsive layouts.
Hooks and custom actions
If you want to display the custom buttons in your plugins, you can use the custom action with the
$attachmentId parameter as the image
post->ID you want the button for. Usage example :
do_action( 'image_regenerate_select_crop_button', $attachmentId );
Images Placeholders Developer Mode
This option allows you to display placeholders for front-side images called programmatically (that are not embedded in content with their src but retrieved with the
wp_get_attachment_image_src function, and the other related WP native functions). If there is no placeholder set, then the default behavior would be to display the full-size image instead of the missing image size.
If you activate the “force global” option, all the images on the front side that are related to posts will be replaced with the placeholders that mention the image size required. This is useful for debugging, to quickly identify the image sizes used for each layout. If you activate the “only missing images” option, all the images on the front side that are related to posts and do not have the requested image size generated will be replaced with the placeholders that mention the image size required. This is useful for showing smaller images instead of full-size images.
This option allows you to exclude globally from the application some of the image sizes that are registered through various plugins and themes options, but you don’t need these in your application at all (these are just stored in your folders and database but not used).
By excluding these, the unnecessary image sizes will not be generated at all.
This option allows you to exclude from the “Image Regenerate & Select Crop Settings” lightbox the details and options for the selected image sizes.
This is useful when you want to restrict from other users the functionality of crop or resize for particular image sizes.
This option means that the original image will be scaled to a max width or a max height specified by the image size you select.
This might be useful if you do not use the original image in any of the layouts at the full size, and this might save some storage space. Leave “nothing selected” to keep the original image as what you upload.
Clean Up All
This option allows you to clean up all the image sizes you already have in the application but you don’t use these at all.
Please be careful, once you click to remove the selected image size, the action is irreversible, and the images generated will be deleted from your folders and database records.
This option allows you to regenerate all the files for the selected image size Please be careful, once you click to regenerate the selected image size, the action is irreversible, and the images already generated will be overwritten.
This option allows you to set a default crop position for the images generated for a particular image size. This default option will be used when you chose to regenerate an individual image or all of these and also when a new image is uploaded.
Use with WP-CLI
The available methods are “regenerate” and “clean up”. The arguments for both methods are the site id (1 for a single site install, or if you are using the plugin in the multi-site environment then you should specify the site id), the post type (post, page, or one of your custom post types), image size name (the thumbnail, medium, etc.).
However, if you do not know all the options you have you can simply start by running the command “sirsc regenerate 1” and for each argument that is not mentioned the plugin will present the list of available values. If you want to regenerate the images for only one post, then the 4th argument can be passed and this should be the post ID.
So, for example, if I would want to regenerate just the thumbnails for a post with the ID = 7, my command would be
sirsc regenerate 1 post thumbnail 7
If I would want to regenerate just the medium images for a post with the id 7, my command would be
sirsc regenerate 1 post medium 7
You can regenerate all images sizes for all the pages like this:
sirsc regenerate 1 page all
Or, you can regenerate all images sizes for the page with the ID = 3 type like this:
sirsc regenerate 1 page all 3
The cleanup command works with the parameters in the exact order and with the types as the regenerate one.
If you would like to support my work, please consider making a donation / buy me a coffee, leave a 5 stars rating, or share this plugin on your feed.
A huge thanks in advance!