woocommerce/packages/js/components/src/product-image
Christopher Allford d2d8d78be1 Moved WCA Packages
This commit moves all of the packages in
`plugins/woocommerce-admin/packages` to their
new home in `packages/js`.
2022-03-18 14:25:26 -07:00
..
stories Moved WCA Packages 2022-03-18 14:25:26 -07:00
test Moved WCA Packages 2022-03-18 14:25:26 -07:00
README.md Moved WCA Packages 2022-03-18 14:25:26 -07:00
index.js Moved WCA Packages 2022-03-18 14:25:26 -07:00
placeholder.js Moved WCA Packages 2022-03-18 14:25:26 -07:00
style.scss Moved WCA Packages 2022-03-18 14:25:26 -07:00

README.md

ProductImage

Use ProductImage to display a product's or variation's featured image. If no image can be found, a placeholder matching the front-end image placeholder will be displayed.

Usage

// Use a real WooCommerce Product here.
const product = {
	images: [
		{
			src: 'https://cldup.com/6L9h56D9Bw.jpg',
		},
	],
};

<ProductImage product={ product } />

Props

Name Type Default Description
width Number 60 The width of image to display
height Number 60 The height of image to display
className String '' Additional CSS classes
product Object null Product or variation object. The image to display will be pulled from product.images or variation.image. See https://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties and https://woocommerce.github.io/woocommerce-rest-api-docs/#product-variation-properties
alt String null Text to use as the image alt attribute