0

On a site that has many different image sizes each time an image is uploaded all the different thumbnail sizes are created causing a fair bit of bloat. What would be the best way of optimising this process?

With a custom post type of ‘product’, where the different product type images have slightly different aspect orientations, should (the plugin) register all the possible image sizes? e.g.

add_image_size('small-A', 45, 67, array('center', 'center'));
add_image_size('small-B', 35, 49, array('center', 'center'));
add_image_size('small-C', 42, 65, array('center', 'center'));
add_image_size('small-D', 50, 50, array('center', 'center'));...

But assuming when the plugin creates a product A, and the front end will never use the other formats for that size; should one only register the necessary sizes for ‘A’ format before running media_handle_upload(), would that affect the front end?

Or, run remove_image_size() on all the unnecessary image sizes just before media_handle_upload()?

Or, is there a different / best-practice approach?

Obviously, impact on performance, scalability and especially impact on storage are of some concern.

Thanks in advance.

(PS. one could conceivably just generate a standard image size and place the appropriately sized image inside that with PHP, but that seems a bit like cheating and possibly creating scaling problems down the road)

0

You can use a plugin for this.

If you want to do it by writing your own code, you may use remove_image_size().

add_action('init', 'wpse325870_remove_plugin_image_sizes');
function wpse325870_remove_plugin_image_sizes() {
    remove_image_size('small-A');
}

Note that you cannot remove reserved image sizes using this function.

0

You don't need to remove the images if you want to increase your site speed. You can optimize and compress the images by using smush images plugin => https://wordpress.org/plugins/wp-smushit/

This plugin can compress and optimize all the images and increase your site speed.In this way you can also save your storage space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.