Created
December 27, 2022 17:13
-
-
Save tdmrhn/48d89c09605be80e4031bdfabf05d57f to your computer and use it in GitHub Desktop.
Wordpress remove extra image sizes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'intermediate_image_sizes', function ( $sizes ) { | |
// keep only 'thumbnail', 'medium', 'large' | |
$targets = ['medium_large', '1536x1536', '2048x2048','shop_thumbnail', 'shop_single', 'shop_catalog', 'woocommerce_thumbnail', 'woocommerce_single', 'woocommerce_gallery_thumbnail']; | |
foreach($sizes as $size_index=>$size) { | |
if(in_array($size, $targets)) { | |
unset($sizes[$size_index]); | |
} | |
} | |
return $sizes; | |
}, 10, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vice versa, i prefer this.