Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add srcset attribute to react product item

weronka9bbe771d1965
diff --git a/saleor/static/js/components/categoryPage/ProductItem.js b/saleor/static/js/components/categoryPage/ProductItem.js
index 68c9480f34..9d1a36a6ee 100644
--- a/saleor/static/js/components/categoryPage/ProductItem.js
+++ b/saleor/static/js/components/categoryPage/ProductItem.js
@@ -28,13 +28,14 @@ class ProductItem extends Component {
render() {
const { product } = this.props;
let productSchema = this.getSchema();
+ let srcset = product.thumbnailUrl1x + ' 1x, ' + product.thumbnailUrl2x + ' 2x';
return (
<div className="col-6 col-md-4 product-list">
<script type="application/ld+json">{productSchema}</script>
<a href={product.url}>
<div className="text-center">
<div>
- <img className="img-responsive" src={product.thumbnailUrl1x} alt="" />
+ <img className="img-responsive" src={product.thumbnailUrl1x} srcSet={srcset} alt="" />
<span className="product-list-item-name" title={product.name}>{product.name}</span>
</div>
<div className="panel-footer">
@@ -63,7 +64,7 @@ export default Relay.createContainer(ProductItem, {
${ProductPrice.getFragment('availability')}
}
thumbnailUrl1x: thumbnailUrl(size: "255x255")
- thumbnailUrl2x: thumbnailUrl(size: "500x500")
+ thumbnailUrl2x: thumbnailUrl(size: "510x510")
url
}
`