我删除了默认图像大小,并使用以下代码添加了自定义图像大小:
// Remove default image sizes
function remove_default_image_sizes( $sizes ) {
/* Default WordPress */
unset( $sizes[ \'thumbnail\' ]); // Remove Thumbnail (150 x 150 hard cropped)
unset( $sizes[ \'medium\' ]); // Remove Medium resolution (300 x 300 max height 300px)
unset( $sizes[ \'medium_large\' ]); // Remove Medium Large (added in WP 4.4) resolution (768 x 0 infinite height)
unset( $sizes[ \'large\' ]); // Remove Large resolution (1024 x 1024 max height 1024px)
/* With WooCommerce */
unset( $sizes[ \'shop_thumbnail\' ]); // Remove Shop thumbnail (180 x 180 hard cropped)
unset( $sizes[ \'shop_catalog\' ]); // Remove Shop catalog (300 x 300 hard cropped)
unset( $sizes[ \'shop_single\' ]); // Shop single (600 x 600 hard cropped)
return $sizes;
}
add_filter( \'intermediate_image_sizes_advanced\', \'remove_default_image_sizes\' );
//
// post thumbnail sizes
add_action( \'after_setup_theme\', \'vkb_setup_theme\' );
function vkb_setup_theme() {
add_theme_support( \'post-thumbnails\' );
set_post_thumbnail_size( 250, 250, true );
add_image_size( \'XS\', 128 );
add_image_size( \'S\', 256 );
add_image_size( \'M\', 512 );
add_image_size( \'XL\', 1024 );
}
//
应该有XS、S、M、XL、Post\\u缩略图和原始大小,即6。然而,当我上传一个大图像(2898 x 2346)进行测试时,我有9个图像,我还有3个尺寸:-1536x1253,-2048x1671,还有一个命名为-缩放为2560x2088。
为什么我有这些额外的尺寸,我如何才能摆脱它们?非常感谢。