/** * disable image sizes */ function ml_disable_image_sizes($sizes) { unset($sizes['thumbnail']); // disable thumbnail size unset($sizes['medium']); // disable medium size unset($sizes['large']); // disable large size unset($sizes['medium_large']); // disable medium-large size unset($sizes['1536x1536']); // disable 2x medium-large size unset($sizes['2048x2048']); // disable 2x large size return $sizes; } add_action('intermediate_image_sizes_advanced', 'ml_disable_image_sizes'); /** * Woocommerce archive "Properly size images" in mobile */ function set_max_srcset_width( $max_width ) { if ( class_exists( 'WooCommerce' ) && ( is_product_category() || is_shop() ) ) { $max_width = 180; } else { $max_width = 768; } return $max_width; } add_filter( 'max_srcset_image_width', 'set_max_srcset_width' ); /** * disable scaled image size */ add_filter('big_image_size_threshold', '__return_false'); /** * disable other image sizes */ function ml_disable_other_image_sizes() { remove_image_size('post-thumbnail'); // disable images added via set_post_thumbnail_size() remove_image_size('another-size'); // disable any other added image sizes } add_action('init', 'ml_disable_other_image_sizes'); /** * disable background auto regeneration */ add_filter( 'woocommerce_background_image_regeneration', '__return_false' );
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter