Skip to content

Instantly share code, notes, and snippets.

@Firsh
Last active November 16, 2022 09:00
Show Gist options
  • Save Firsh/50ffc258e6540b7573a03603ff1c5a89 to your computer and use it in GitHub Desktop.
Save Firsh/50ffc258e6540b7573a03603ff1c5a89 to your computer and use it in GitHub Desktop.
Custom image sizes and unregistering unused ones for WordPress
<?php
// This removes the hard limit and oprhan originals
add_filter('big_image_size_threshold', '__return_false');
// This is pretty nice custom skipper
add_filter('intermediate_image_sizes_advanced', 'remove_default_images');
function remove_default_images($sizes)
{
//unset($sizes['small']); // 150px
//unset($sizes['medium']); // 300px
unset($sizes['large']);
//unset($sizes['medium_large']);
unset($sizes['1536x1536']);
unset($sizes['2048x2048']);
return $sizes;
}
update_option('medium_large_crop', 0);
update_option('medium_large_size_w', 760);
update_option('medium_large_size_h', 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment