Animated gifs are getting more popular on the web (again) and currently there is no good tool for resizing animated gifs.
So I want to disable resizing/generation of image sizes for the gif mimetype and just save the original gif.
Someone that can help me out with this? Which filter to use will be a good start.
image_make_intermediate_size was not the hook I was looking for, but intermediate_image_sizes_advanced.
Here is a working code:
function disable_upload_sizes( $sizes, $metadata ) {
// Get filetype data.
$filetype = wp_check_filetype($metadata['file']);
// Check if is gif.
if($filetype['type'] == 'image/gif') {
// Unset sizes if file is gif.
$sizes = array();
}
// Return sizes you want to create from image (None if image is gif.)
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'disable_upload_sizes', 10, 2);