最合适的回答,由SO网友:Lasse M. Tvedt 整理而成
image\\u make\\u intermediate\\u size不是我要找的挂钩,而是intermediate\\u image\\u size\\u advanced。
以下是工作代码:
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);