The plugin appends two custom buttons that allows you to regenerate and crop the images, provides details about the image sizes registered in the application and the status of each image sizes 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 debug if necessary.
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 sizes 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 “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 in “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 layout.
admin_enqueue_scripts, init, add_meta_boxes, wp_ajax_, plugins_loaded, admin_menu, intermediate_image_sizes_advanced, added_post_meta, image_downsize, admin_post_thumbnail_html, edit_form_top, image_regenerate_select_crop_button
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
4.0 – Tested up to 4.6.1 version, update the image buttons to work with WP >= 4.6 new hooks parameters, changes for the image buttons backward compatibility (core versions less than 4.6)
3.3 – Tested up to 4.4.2 version, code cleanup, fix typo, fix element position in edit media screen
3.0 – Forced original resize for already uploaded images when using the regenerate option.
2.0 – Default crop configuration and WP-CLI extension.
1.0 – Development version.
If you want to display the custom buttons in your plugins, you can use the custom action with $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, 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 a 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 debug, to quick 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 generate, 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 layout at the full size, and this might save some storage space.
Leave “nothing selected” to keep the original image as what you upload.
This option allows you to cleanup 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, the images generated will be deleted from your folders and database records.
This option allows you to regenerate all the image for the selected image size Please be careful, once you click to regenerate the selected image size, the action is irreversible, the images already generated will be overwritten.
This option allows you to set a default crop position for the images generated for 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.
The available methods are “regenerate” and “cleanup”. The arguments for both methods are the site id (1 for single site install, or if you are using the plugin in 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 (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 exactly parameters order and types as the regenerate one.
Needed WP-generated images recreated in a pinch, and this plugin did just the trick!
This plugin works really well in conjunction with image compression plugins like ShortPixel and Imagify, which put a limit on how many images you can optimize with their free plans. Each thumbnail counts as an image, so if you have a lot of custom image sizes set by either your theme or a plugin (Co-Authors Plus, I'm looking at you. And WooCommerce, too), you might be wasting credit on thumbnails that you'll never even use. Not to mention that I just don't like the idea of all those thumbnails cluttering up my uploads folders, even though storage space isn't usually an issue on hosting accounts.
Because it's technically pretty much impossible (I was researching how to do it) to create only certain sizes of image when you upload them, you have to get rid of the unnecessary ones after the fact, which is what this plugin does.
The UI is a little confusing. You need to check the box labeled "Global Ignore" to delete an image size from a particular post type. To me, "Ignore" suggests that the plugin will skip that image size. A better label would probably be "Remove all" or "Remove from $post_type". Then you have to save the settings. Then you go back and tell the plugin to clean up the unwanted images.
The other problem is the General Settings (Used as default for all images), and the fact that if you don't set any of these, you get warnings that the settings haven't been configured. It's true that if I have leftover unused image sizes, I might want to get rid of them everywhere. But although it's hard to specify what image sizes are created when uploading an image, it's very easy to remove an image size entirely by editing your functions.php file. If the size is created by your theme, find the
add_image_size() function that creates it and comment out that line. No more thumbnails of that size will be created. To get rid of a default image size or one created by a plugin, use
This plugin is useful and pretty much the only one I've found that will remove excess thumbnails successfully on WP 4.7, but it could use a little polishing.
- Tested up to 4.6.1 version
- Update the image buttons to work with WP >= 4.6 new hooks parameters
- Changes for the image buttons backward compatibility (core versions less than 4.6)
- Tested up to 4.4.2 version
- Fix typo
- Fix element position in edit media screen
- Tested up to 4.3.1 version
- Add * in front of options that have settings applied.
- Add the forced original resize execution for already uploaded images when using the regenerate option (this will not just resize the images for the selected image size but will also alter the original images).
- Add the default crop configuration for each image size.
- And the WP-CLI extension.
Contributors & Developers
Image Regenerate & Select Crop is open source software. The following people have contributed to this plugin.Contributors