woocommerce/woocommerce

Featured product image is not responsive

Open

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

在 GitHub 查看
 (15 评论) (1 反应) (0 负责人)PHP (10,294 star) (10,695 fork)batch import
EnhancementGood First IssueKirigamiblock: featured categoryblock: featured product

描述

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.

贡献者指南