【发布时间】:2016-11-09 06:18:53
【问题描述】:
我正在尝试更改 WooCommerce 缩略图裁剪位置。我发现这段代码可以帮助改变大小:
add_action( 'init', 'yourtheme_woocommerce_image_dimensions', 1 );
/**
* Define image sizes
*/
function yourtheme_woocommerce_image_dimensions() {
$catalog = array(
'width' => '100', // px
'height' => '100', // px
'crop' => 0
);
// Image sizes
update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs
}
我做了一些尝试,例如将裁剪 0 更改为 array("center", "bottom"),但它不起作用:
function yourtheme_woocommerce_image_dimensions() {
$catalog = array(
'width' => '300', // px
'height' => '400', // px
'crop' => 'array("center", "bottom")'
);
// Image sizes
update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs
}
这也没有成功:
if (function_exists( 'add_image_size' )){
add_image_size( 'shop_catalog', 300, 400, array( 'center', 'bottom' ) );
}
无论如何我可以改变它吗?
谢谢。
【问题讨论】:
标签: php wordpress woocommerce crop image-size