Last active
March 11, 2023 10:04
-
-
Save gmmedia/8705298d147f114f4261651a6dd011b6 to your computer and use it in GitHub Desktop.
WordPress: Remove unwonted image sizes, like medium_large, 1536x1536, 2048x2048
This file contains hidden or 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 | |
/* | |
* 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