Last active
October 6, 2021 13:06
-
-
Save mitchellkrogza/0555b4f6612d5d059ba7ea6186af9d79 to your computer and use it in GitHub Desktop.
Remove unnecessary wordpress 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
/* | |
* WordPress: Remove unwanted image sizes. | |
* Remove the three sizes medium_large, 1536x1536, 2048x2048 | |
* Not needed for 99% of Woocommerce stores | |
*/ | |
add_filter('intermediate_image_sizes', function($sizes) { | |
return array_diff($sizes, ['medium_large']); // Medium Large (768 x 0) | |
}); | |
add_action( 'init', 'j0e_remove_large_image_sizes' ); | |
function j0e_remove_large_image_sizes() { | |
remove_image_size( '1536x1536' ); // 2 x Medium Large (1536 x 1536) | |
remove_image_size( '2048x2048' ); // 2 x Large (2048 x 2048) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment