admin管理员组文章数量:1122846
I'm converting a site across to wordpress that is heavy on imagery. With the fact the products are art based the original sizes have little to no continuity. Now on the product page itself this isn't an issue but in woocommerce the catalog mode is thumbnail sizing is all over the place so alignment looks horrible. Complicating the matter is one of the categories products are more shaped like a door being rather tall by comparison so setting a standard one size for all doesn't work.
Were it is just the thumbs in catalog mode I need to clean up what is the best way to address that with existing images. It is easy to standardize moving forward to address this when taking photos but need a solution to port without manually doing it for hundreds of products.
I'm converting a site across to wordpress that is heavy on imagery. With the fact the products are art based the original sizes have little to no continuity. Now on the product page itself this isn't an issue but in woocommerce the catalog mode is thumbnail sizing is all over the place so alignment looks horrible. Complicating the matter is one of the categories products are more shaped like a door being rather tall by comparison so setting a standard one size for all doesn't work.
Were it is just the thumbs in catalog mode I need to clean up what is the best way to address that with existing images. It is easy to standardize moving forward to address this when taking photos but need a solution to port without manually doing it for hundreds of products.
Share Improve this question asked Jun 27, 2018 at 14:59 rnbrnb 11 bronze badge1 Answer
Reset to default 0Set the product thumbnail size and enforce whichever form of cropping gives you the consistency you're looking for. This will let you set whatever width you prefer:
<?php
function wpse_307110_override_thumbnail_sizes() {
$theme_support = get_theme_support( 'woocommerce' );
$theme_support = is_array( $theme_support ) ? $theme_support[0] : array();
// change 150 to whatever width you need
$theme_support['thumbnail_image_width'] = 150;
remove_theme_support( 'woocommerce' );
add_theme_support( 'woocommerce', $theme_support );
}
add_action( 'after_setup_theme', 'wpse_307110_override_thumbnail_sizes', 10 );
?>
Next, to affect cropping:
Crop square: update_option( 'woocommerce_thumbnail_cropping', '1:1' );
Don't crop at all: update_option( 'woocommerce_thumbnail_cropping', 'uncropped' );
Or crop to custom ratio:
// set width and height as needed: this creates a 4:3 ratio
// so if width is 150px, height will be 113px (112.5 rounded up)
update_option( 'woocommerce_thumbnail_cropping', 'custom' );
update_option( 'woocommerce_thumbnail_cropping_custom_width', '4' );
update_option( 'woocommerce_thumbnail_cropping_custom_height', '3' );
Then, use a plugin that regenerates all thumbnails - this will regenerate every image size for all the existing images.
本文标签: woocommerce offtopicProduct thumbnail size in catalog
版权声明:本文标题:woocommerce offtopic - Product thumbnail size in catalog 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736293867a1929234.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论