Wocart

@wocart/storefront v3.1.0


@wocart/storefront / index / productImageSource

Function: productImageSource()

productImageSource(product): string

The product's representative image URL, or null when it has none.

Prefers the merchant's chosen cover, falls back to the first usable gallery image, and treats a blank url as no image at all — so a caller renders its placeholder exactly when the product genuinely has no photograph.

Parameters

product

ProductImageSourceInput

Returns

string

Example

TypeScriptCode
const src = productImageSource(product); // Product | ProductList const thumbnail = src ? mediaImageUrl(src, { width: 160, height: 160, fit: "cover" }, config.media) : null;