Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove WordPress default image sizes to save disk space
<?php
function remove_default_image_sizes( $sizes) {
// sizes defined in media settings
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
// auto-generated images since WP 5.3
unset( $sizes['medium_large']);
unset( $sizes['1536x1536']);
unset( $sizes['2048x2048']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'remove_default_image_sizes');
?>
@jnicol
Copy link
Author

jnicol commented Feb 21, 2020

Comment out the sizes you want to keep.

ALWAYS keep thumbnail and medium image sizes: WP uses them for thumbnails in the media library and will fall back to full size image if medium images don't exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment