add_filter( \'intermediate_image_sizes_advanced\', function ( $sizes ) {
$allowed = [ \'thumbnail\', \'medium\', \'large\', \'medium_large\' ];
foreach ( $sizes as $name => $size ) {
if ( ! in_array( $name, $allowed ) ) {
unset( $sizes[ $name ] );
}
}
return $sizes;
} );
我最终用我允许的作物设置了一个数组,然后取消设置任何不存在的东西。