简体   繁体   English

设置与产品尺寸不同的 Woocommerce 产品类别缩略图尺寸

[英]Set Woocommerce Product Category Thumbnail Size Different From Product Size

I need help changing some settings in my WordPress default image sizes.我需要帮助更改 WordPress 默认图像大小中的一些设置。 I've been looking for an answer everywhere but could not find any good answers.我一直在到处寻找答案,但找不到任何好的答案。

Let me first define what I am talking about: -Product photo: the regular product photo in catalog view.让我首先定义我在说什么: - 产品照片:目录视图中的常规产品照片。 -Product category photo: this is the photo for a certain product category (see photo 1 below) (say hairloss treatments), which once clicked would take you to a page with multiple products under that category (say hairloss products). - 产品类别照片:这是某个产品类别的照片(见下面的照片 1)(比如脱发治疗),一旦点击,您就会进入一个页面,该页面包含该类别下的多个产品(比如脱发产品)。

Right now it looks like the size for the product images (in catalog view) are equal to my product category thumbnail sizes.现在看起来产品图像的大小(在目录视图中)等于我的产品类别缩略图大小。 This does not look good because product photos are ok to be square and small but category photos should be more of a rectangular shape.这看起来不太好,因为产品照片可以是方形和小尺寸的,但类别照片应该更像矩形。 I tried to change the category thumbnail sizes by going to CSS and changing the width like this:我试图通过转到 CSS 并像这样更改宽度来更改类别缩略图大小:

 .categories-style-default .cat-design-default .category-content .product-category-thumbnail img { width: 350px !important }

The image block for the category changed to 350px and the image just stretched but still used a resized image default size of (230px width, which is that of the product image default).该类别的图像块更改为 350 像素,图像刚刚拉伸,但仍使用调整后的图像默认尺寸(230 像素宽度,这是产品图像的默认尺寸)。

Can you help me figure this out?你能帮我解决这个问题吗? I am not an expert in coding but if you give me steps I can do it!我不是编码专家,但如果您给我步骤,我可以做到!

Here's what my category thumbnail looks like now:这是我的类别缩略图现在的样子:

这是我的类别缩略图现在的样子

Here's how it should look like:它应该是这样的:

这是它的样子

Here's the code for the category image:这是类别图像的代码:

这是类别图像的代码

Here's the default sizing for products in WooCommerce:以下是 WooCommerce 中产品的默认尺寸:

这是 woocommerce 中产品的默认尺寸

Thanks!!谢谢!!

Use object-fit.使用对象匹配。 The CSS object-fit property is used to specify how an should be resized to fit its container. CSS object-fit 属性用于指定应如何调整大小以适合其容器。

img {
  width: 200px;
  height: 300px;
  object-fit: cover;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM