Skip to content

Instantly share code, notes, and snippets.

@jnicol
Last active November 18, 2020 21:52
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 jnicol/fea17641b9f8a87432fea2964aa646d5 to your computer and use it in GitHub Desktop.
Save jnicol/fea17641b9f8a87432fea2964aa646d5 to your computer and use it in GitHub Desktop.
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