Skip to content

Instantly share code, notes, and snippets.

@gmmedia
Last active March 11, 2023 10:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gmmedia/8705298d147f114f4261651a6dd011b6 to your computer and use it in GitHub Desktop.
Save gmmedia/8705298d147f114f4261651a6dd011b6 to your computer and use it in GitHub Desktop.
WordPress: Remove unwonted image sizes, like medium_large, 1536x1536, 2048x2048
<?php
/*
* WordPress: Remove unwonted image sizes.
* In this code I remove the three sizes medium_large, 1536x1536, 2048x2048
* See full article:
*/
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