Home My Plugins Image Regenerate & Select Crop

Image Regenerate & Select Crop

The plugin allows to manage advanced settings for images, to override the native medium and large crop option, to register new custom image sizes. It allows you to regenerate and crop the images (bulk or individually), provides details about the image sizes registered in the application and the status of each image sizes for images, allows you to cleanup the unnecessary images. Check this out if you need a “one-stop solution” for image optimization.

Image Regenerate & Select Crop Banner

Option to Enable Placeholders

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!

This option allows you to display placeholders for the front-side images called programmatically (the images that are not embedded in the content with their src but exposed using WordPress native functions). If there is no placeholder set, then the WordPress default behavior would be to display the full-size image instead of the missing image size, hence your pages might load slower, and when using grids, the items would not look even.

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, and perhaps to help you regenerate the mission ones or decide what to keep or what to remove.

If you activate the “only missing images” option, all the programmatically called 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 the full-size images (as WordPress does by default), hence for speeding up the pages loading.

Option to Exclude Image Sizes

This plugin provides the option to select image sizes that will be excluded from the generation of the new images. By default, all image sizes defined in the system will be allowed (these are programmatically registered by the themes and plugins you activate on your site, without you even knowing about these).

You can set up a global configuration, or a more specific configuration for all images attached to a particular post type. If no particular settings are made for a post type, then the default general settings will be used.

Reset

The reset button allows for cleanup of all settings for this plugin. The reset will not remove the custom registered image sizes, but only the settings.

Apply the settings for the selected option

You can select the general settings that apply to all, or only one of the post types if necessary. The options for which you made some settings are marked with * in the dropdown below. When you select a post type the general options will not be editable, only these that can apply to the images attached to a post will be available for updates.

General settings

  • show small buttons on the media screen
  • show attachment image sizes summary on the media screen
  • show buttons on the media screen in grid mode
  • filter and expose the image sizes available for the attachment display settings in the media dialog (any registered available size, even when there is no explicit filter applied)
  • turn off the WooCommerce background thumbnails regenerate
  • bulk regenerate/cleanup execution starts from the most recent files
    • This option allows you to run the bulk cleanup and bulk regenerate actions starting from the most recent files you have in the media library until the eldest image is found. This is useful if you know when you can pause/stop the bulk actions, for example when you already run the bulk actions for older files and you only need to run this for more recent uploads.
    • By default, the bulk actions will run from the oldest to the newest files.
  • do not clean up the settings after the plugin is deactivated
  • turn on the custom debug log for monitoring the execution of the event

Cron tasks

  • Execute bulk actions using the WordPress cron tasks instead of the default interface
    • option to specify the number of images to be regenerated at each cron task iteration
    • option to specify the number of images to be cleanup at each cron task iteration
  • Cancel all currently scheduled tasks that aim to regenerate or clean up the images.

Other settings

  • generate only perfect fit sizes
    • This option allows you to generate only images that match exactly the width and height of the crop/resize requirements when the option is enabled. Otherwise, the script will generate anything possible for smaller images.
  • attempt to upscale when generating only perfect fit sizes
    • This option allows you to upscale the images when using the perfect fit option. This allows images that have at least the original width close to the expected width or the original height close to the expected height (for example, the original image has 800×600 and the crop size 700×700) to be generated from an upscaled image.
  • regenerate only missing files
    • This option allows you to regenerate only the images that do not exist, without overriding the existing ones.
  • regenerate/cleanup only featured images
    • This option allows you to regenerate/cleanup only the images that are set as the featured images for any of the posts.

General cleanup

It is recommended to run the cleanup using the command line tools.

However, if you do not have access to wp-cli on your server, you could run the cleanup actions by using the cron tasks, or, if you have a small set of images to clean up, by using the plugin dialog.

  • Cleanup unused files and keep currently registered sizes files
    • This type of cleanup is performed for all the attachments, and it removes any attachment unused files and keeps only the files associated with the currently registered image sizes. This action is also changing the attachment metadata in the database, and it is irreversible.
wp sirsc cleanup
  • Keep only the original/full-size files
    • This type of cleanup is performed for all the attachments, and it keeps only the file associated with the original/full size. This action is also changing the attachment metadata in the database, and it is irreversible. After this process is done, you need to regenerate the files for the desired image sizes.
wp sirsc rawcleanup

Image sizes options

Ignore

This option allows you to exclude globally from the application some of the image sizes that are registered through various plugins and themes options, that you perhaps do not need at all in your application (these are just stored in your folders and database but not actually used/visible on the front-end).

By excluding these, the unnecessary image sizes will not be generated at all.

Quality

The quality option is allowing you to control the quality of the images that are generated for each of the image sizes, starting from the quality of the image you upload. This can be useful for performance.

However, please be careful not to change the quality of the full image or the quality of the image size that you set as the forced original.

Setting a lower quality is recommended for smaller image sizes, that are generated from the full/original file.

Force original

This option means that when uploading an image, the original image will be replaced completely by the image size you select (the image generated, scaled, or cropped to a specific width and height will become the full size for that image going further).

This can be very 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 full/original image as the file you upload (default WordPress behavior).

Hide preview

This option allows you to hide from the “Image Regenerate & Select Crop Settings” lightbox the details and options for the selected image sizes (when you or other admins are checking the image details, the hidden image sizes will not be shown)

This is useful when you want to restrict from other users the functionality of crop or resize for particular image sizes, or to just hide the image sizes you added to global ignore

If you set the image size as ignored or unavailable, this will not be listed on the media screen when the dropdown of image sizes will be shown.

Default crop

This option allows you to set a default crop position for the images generated for a particular image size. This option will be applied when you chose to regenerate an individual image or all of these, and also when a new image is uploaded.

Cleanup

This option allows you to clean up all the images generated for a particular image size you already have in the application, and that you do not use or do not want to use anymore on the front-end.

Please be careful, once you click to remove the images for the selected image size, the action is irreversible, the images generated up this point will be deleted from your folders and database records.

You can regenerate these later if you click the Regenerate button.

Regenerate

This option allows you to regenerate the images for the selected image size.

Please be careful, once you click the button to regenerate the selected image size, the action is irreversible, and the images already generated will be overwritten.

wp sirsc regenerate

Advanced rules

The advanced custom rules you configure are global and will override all the other settings you set.
Please be aware that the custom rules will apply only if you actually set up the post to use one of the advanced rules, and only then upload images to that post.

Very important: the order in which the rules are checked and have priority is: post ID, post type, post format, post parent, post tags, post categories, and other taxonomies. Any of the rules that match first in this order will apply to the images that are generated when you upload images to that post (and the rest of the rules will be ignored). You can suppress at any time any of the rules and then enable these back as it suits you.

Summary for version 6

6.2.2

  • Tested up to 5.9.2
  • Fixed crop typo in sub-sizes info.
  • Bypassed placeholder for image sizes that do not have a width or height defined.
  • Excluded new core post types from the list of image size options.

6.2.1

  • Tested up to 5.9
  • Clear attachment cache before re-computing the object after the image regenerate

6.2.0

  • Tested up to 5.8.2.
  • Added placeholder fallback
  • Change filter priority to apply earlier the available sizes
  • Fix warnings for info not available in some of the core versions
  • Fix warnings for estimated sizes missing width or height
  • Attempt to bypass scaled size naming
  • Updated sizes filter for backward compatibility
  • Limit the length of the log
  • Trace in the bulk log the WP-CLI command executions
  • Styles adjustments (for Chromium)

6.1.0

  • Tested up to 5.8.1.
  • Added the wp-CLI commands hints for the bulk features.
  • Added the wp-CLI command to rename files for SEO adon active.
  • Added the new option that turns on/off the buttons from the media screen when switched to grid mode.

6.0.3

  • Implemented fallback save for media settings as the native hook in 5.8 is not firing consistently.
  • Updated the media settings UI
  • Setup default bulk action in reverse for new installs

6.0.2

  • Add back action when attachment gets deleted

6.0.1

  • Fix medium large crop option update
  • Added close icon to the info lightbox (decorative only, the lightbox is closing on any click)
  • Style adjustments for the enabled custom rules
  • Fix cleanup button class typo

6.0.0

  • Tested up to 5.8.
  • General settings UI changes, accessibility, a better grouping of settings and options, separated and marked differently for clarity the settings that are global form the settings that can apply to images attached to the selected post type, sticky heading for the images sizes listing, spinners, mobile view update.
  • Advanced rules UI changes: accessibility, better differentiate the active and suppressed rules, sticky heading and save button, mobile view update.
  • Added the new reset settings feature (resets the plugin settings without removing the custom registered image sizes).
  • Added the new option to bulk regenerate/cleanup execution starting from the most recent files.
  • Added the new option to turn on the custom debug log for monitoring the events and execution related to the regeneration and cleanup of images.
  • Added the new option to execute bulk actions using the WordPress cron tasks instead of the default interface (regenerate and cleanup batches size too).
  • Updated the bulk cleanup and bulk regenerate dialogs and buttons to differentiate when the cron tasks are enabled, also added the option to cancel all currently scheduled tasks that aim to regenerate or clean up the images (as a fallback option).
  • Added the new debug tab with the bulk actions and tracer logs (options to clean up and refresh).
  • Moved in the debug tab the status/debug details (previously available in the Import/Export addon).
  • Add-ons thumbnails updates.
  • Updated the export registered image sizes snippet to use boolean values for the crop parameter.
  • Changes to expose the custom placeholders for each image size when the placeholders option is enabled (global or only missing) and the option to regenerate another file for each (helps when the random colors assigned do not provide enough contrast for troubleshooting).
  • Add-ons styles updates and options to pause/resume bulk actions.
  • Fix the counters for bulk actions (thumbnail vs shop_thumbnail).
  • Code refactoring and updates for PHP’s latest stable versions.
  • Optimize the info lightbox, lazy loading of the embedded images, sticky heading for clarity, and mobile view update.
  • Added in the info lightbox the option to clean up metadata for the images sizes that match the original (metadata optimization)
  • Decouple the image size file deletion in the cases with multiple matched image sizes (this will clean up metadata for additional image sizes that match the same filename, and will remove the file as well when the file matches only one size).
  • Added auto-update preview on the page when the image size file is updated and is present on the current view.
  • Added the individual image buttons in the media library view in the grid mode.
  • Fix assets enqueue issue for usage with core versions >= 5.6.
  • Completely decoupled the plugin from jQuery legacy code.

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!

See some other details and demo.

6.0.0