我想将图库缩略图的缩略图大小更改为最大60x60px。不用修剪。
我在WooCommerce文档中发现了以下钩子:
add_filter( 'woocommerce_gallery_thumbnail_size', function( $size ) {
return array('width' => 60, 'height' => 60, 'crop' => 0, );
} );
60x60版本在服务器上。但WooCommerce并没有使用它,而是裁剪过的。
function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce', array(
'thumbnail_image_width' => 240,
'single_image_width' => 450,
'gallery_thumbnail_image_width' => 60,
) );
add_theme_support( 'wc-product-gallery-slider' );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
当我删除它时,WooCommerce的缩略图大小会被完全忽略。
我做错什么了吗?
它适用于其他图像大小,如:
add_filter( 'woocommerce_get_image_size_thumbnail', function( $size ) {
return array('width' => 240, 'height' => 240, 'crop' => 0, );
} );
add_filter( 'woocommerce_get_image_size_single', function( $size ) {
return array('width' => 450, 'height' => 450, 'crop' => 0, );
} );
这些图像具有最大宽度和高度,不会被裁剪。
但是图库缩略图版本总是被裁剪。