Skip to content

Instantly share code, notes, and snippets.

@mitchellkrogza
Last active October 6, 2021 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchellkrogza/0555b4f6612d5d059ba7ea6186af9d79 to your computer and use it in GitHub Desktop.
Save mitchellkrogza/0555b4f6612d5d059ba7ea6186af9d79 to your computer and use it in GitHub Desktop.
Remove unnecessary wordpress image sizes
/*
* 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