Home / Disable / Disable default WordPress image sizes
Duplicate Snippet

Embed Snippet on Your Site

Disable default WordPress image sizes

Code Preview
php
<?php
// Disable default WordPress image sizes
add_filter('intermediate_image_sizes', '__return_empty_array');
// Disable large scaled image size
add_filter('big_image_size_threshold', '__return_false');
// Disable WooCommerce image sizes and prevent WooCommerce from regenerating sizes
add_action('after_setup_theme', function () {
    // WooCommerce image sizes
    remove_image_size('woocommerce_thumbnail');
    remove_image_size('woocommerce_single');
    remove_image_size('woocommerce_gallery_thumbnail');
    // Clear WooCommerce image dimensions to stop regeneration
    update_option('woocommerce_thumbnail_image_width', 0);
    update_option('woocommerce_single_image_width', 0);
    update_option('woocommerce_gallery_thumbnail_image_width', 0);
}, 20);

Comments

Add a Comment