【发布时间】:2015-12-19 08:44:11
【问题描述】:
因此,目前类别的图像是设定的高度/宽度 是否可以将其设置为不调整大小,而是随图像的大小而变化。 网站:http://www.timandted.com/shop/ 示例:http://goo.gl/0KLCah
【问题讨论】:
标签: image resize woocommerce categories shop
因此,目前类别的图像是设定的高度/宽度 是否可以将其设置为不调整大小,而是随图像的大小而变化。 网站:http://www.timandted.com/shop/ 示例:http://goo.gl/0KLCah
【问题讨论】:
标签: image resize woocommerce categories shop
是的……你需要更新图像循环的输出……
remove_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action('woocommerce_before_shop_loop_item_title', 'new_woocommerce_template_loop_product_thumbnail', 10);
function new_woocommerce_template_loop_product_thumbnail() {
echo '<img src="' . wp_get_attachment_image_src(get_post_thumbnail_id(), 'full') . '">';
}
你也可以这样使用:
remove_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action('woocommerce_before_shop_loop_item_title', 'new_woocommerce_template_loop_product_thumbnail', 10);
function new_woocommerce_template_loop_product_thumbnail() {
$new_image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
echo '<img src="' . $new_image_src . '">';
}
如果您想使用目录大小并调整元素中的某些尺寸,您可以使用wp_get_attachment_image_src(get_post_thumbnail_id(), 'shop_catalog') 拉入目录裁剪图像。
【讨论】:
functions.php 文件中。