woocommerce/woocommerce

Featured product image is not responsive

已关闭

#42,661 创建于 2021年11月3日

 (15 条评论) (1 个反应) (1 位负责人)PHP (10,695 个派生)batch import
Blocks/Patterns/TemplatesEnhancementGood First IssueKirigamiblock: featured categoryblock: featured productready for engineering

仓库指标

星标
 (10,294 个星标)
PR 合并指标
 (平均合并 9天 12小时) (30 天内合并 423 个 PR)

描述

Describe the bug

Hi, the woocommerce/featured-product block always uses a single background image size even on small viewports.

To reproduce

Steps to reproduce the behavior:

  1. Add a featured product block on a page/post
  2. view said page/post in frontend
  3. inspect the block element in devtools
  4. the block uses background-image: url(...);. Therefore the browser cannot select an appropriately sized image for the current viewport size.

Expected behavior

The block should use an <img> or <picture> element w/ appropriate srcset and sizes attributes.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

WordPress (please complete the following information):

  • Core version: 5.8.1
  • WooCommerce version: 5.8.0
  • WooCommerce Blocks version: bundled w/ woocommerce

Desktop (please complete the following information):

  • OS: irrelevant
  • Browser irrelevant
  • Version irrelevant

Smartphone (please complete the following information):

  • Device: irrelevant
  • OS: irrelevant
  • Browser irrelevant
  • Version irrelevant

Additional context

See the core/cover block for an example of how it could be done.

贡献者指南