Image Regenerate & Select Crop WordPress Plugin
[plugin_version]
The plugin allows you to manage advanced settings for images, to override the native medium and large crop options, and 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 sub-sizes for images, and allows you to clean up the unnecessary images. Check this out if you need a “one-stop solution” for image optimization.
Plugin Options
Screenshots from the plugin UI
Option to Enable Placeholders
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 full-size images (as WordPress does by default), hence speeding up the page loading.
Option to Exclude Image Sizes
This plugin provides the option to select image sizes that will be excluded from generating new image files. By default, all sub-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 the 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 those 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 the attachment sub-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 the theme 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, unnecessary sub-sizes will not be generated at all.
Quality
The quality option allows 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 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 is 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 choose 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 to 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, this is the order in which the rules are checked and have priority: 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.
WP-CLI FAQ
How to use the plugin wp-cli commands?
The 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
The commands can be used with two flags:
--verbose
– this attempts to give a detailed description of the execution--force
– available for the cleanup command
How to clean up images using wp-cli commands?
To 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).
How to raw clean up images using wp-cli commands?
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)
How to reset clean-up images using wp-cli commands?
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)
How to regenerate images using wp-cli commands?
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
You can download the free plugin from the WordPress repository.
Changelog for Version 6-8
8.0.3
- Attempt to fix the SVG dimensions when the core feature fails on upload (when SSL operation failed due to routines:tls_process_server_certificate:certificate verify)
- Fixed cron schedule warning for custom frequency
8.0.2
- Removed the GLOB_BRACE from the code, as that is not available on some non GNU systems
8.0.1
- Tested up to 6.6
- Refined the filter for fixing the file name on upload, following the best practice for SEO and accessibility
8.0.0
This is a major update, please keep a backup of your files before updating
- Tested up to 6.5.3
- Compatibility updates for core >= 6.5
- Set default quality to 90 (aligned with the most recent core changes)
- Styles updates to inherit the main color from the admin theme and simplified the theme colors
- Accessibility improvements
- Performance improvements
- Placeholders optimization
- Translations updates
- Improved the placement of the buttons in the media dialogs
- Improved the upscale option so that sub-sizes with both width and height bigger that the original file to be generated (previously, at least one dimension needed to match the original)
- Added a note in the debug screen if the site configuration does not allow for the logs to be written
- Fixed the error produced in the custom logs when the FS_METHOD is defined and not direct
- Fixed the buttons for the featured image when selected in new draft posts
- Fixed the loaded rules for the image details lightbox
- Fixed the issue that made videos have 0x0 dimensions in the media library
7.33
- Adjusted the initial threshold to match better the portrait images
- Cleanup artefact images
- Fixed warnings for unidentified crop position
7.3.2
- Changed the path of the logs to use the uploads folder
- Fixed the final file name and output info for the forced original size
7.3.1
- Added extra random string to hashed log files names
7.3.0
- Tested up to 6.4
- Security updates – added the log index file and hashed log files names
7.2.4
- Tested up to 6.3.1
- Added and extra check for writable log folder to avoid code warnings (the core file system touch is not reliable to do the check)
- Refactored the image quality so that the images will create sub-sizes at the expected quality on upload too (to overcome the core lack of hooks for sub-sizes quality when processing uploads)
- Exposed all image sizes in the editor settings
7.2.3
- Fixed the option “bulk regenerate/cleanup execution starts from the most recent files” remaining auto selected
7.2.2
- Tested up to 6.3
- Minor styles updates
7.2.1
- Forced release to fix the previous deployment issue
7.2.0
- Tested up to 6.2.2
- Security updates – limited the special features to only admins
- Added WP-CLI commands extensive details to the FAQ section of the plugin readme
- Added the info, regenerate, and cleanup buttons in the select/upload media dialog
- Fixed some warnings when using the reset cleanup command
7.1.0
- Tested up to 6.2
- Added the option to disable the verbose tracer log, hence, log only the main events
- Added the filter
sirsc_keep_scaled
, which allows for preserving the scaled version - Added new Elementor and WooCommerce post types to exclude lists
- Updated the wp-cli regenerate command to be in sync with the “regenerate only missing files” and “regenerate/cleanup only featured images” settings from the bulk actions
- Updated the wp-cli commands description, synopsis, and options details
- Fixed the admin menu overlay
7.0.1
- Fixed warnings when the initial metadata is incorrect (missing width or height) and bypassed summary
- Fixed the SVGs preview in the admin listing when the image metadata is missing width or height
7.0.0
- Tested up to 6.1.1
- WP 6.1.1 compatibility updates
- PHP 8 compatibility updates
- WooCommerce compatibility updates
- Added the custom images sizes to the editor images sizes (to make these available in the image and gallery core blocks when the sub-sizes are available)
- Added a small performance optimization for the custom advanced rules hook
- Added the options for separate custom rules for featured images
- Added the matched rule in the tracer log (for more details about generating sub-sizes and troubleshooting)
- Added two new filters, one for removing the update notification and one for removing the top notification
- Fixed the mime type warning on the SVG upload
- Minor styles updates
- Dependencies updates
- Translations updates
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 sizes’ options.
6.2.1
- Tested up to 5.9
- Clear the 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 sub-size naming
- Updated sizes filter for backward compatibility
- Limit the length of the logs
- 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 a close icon to the info lightbox (decorative only, the lightbox is closing on any click)
- Style adjustments for the enabled custom rules
- Fix the 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 differentiation of 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 debug tab the status/debug details (previously available in the Import/Export addon).
- Add-ons’ thumbnail 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 the option to pause/resume bulk actions.
- Fix the counters for bulk actions (
thumbnail
vsshop_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 images’ 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.
Click the heart.
If you would like to support my work, consider making a donation, buy me a coffee, leave a 5 stars rating, or share this on your feed.
A huge thanks in advance!
Premium Features
The plugin offers additional advanced features, bundled into the following premium add-ons:
Images SEO Premium Extension
This extension allows you to rename the image files (bulk rename, individual rename, or image rename on upload). Also, the extension provides the feature to override the attachment attributes…
€ 10.00Add to cart
Uploads Folder Info Premium Extension
€ 4.00Add to cart
Uploads Inspector Premium Extension
This extension allows you to analyze the files from your uploads folder (even the orphaned files, these not associated with attachment records in the database) and see details about their…
€ 6.00Add to cart