Skip to content

Commit

Permalink
Use default product backup image
Browse files Browse the repository at this point in the history
1. The image from a product variant isn't garunteed to exist. In the rest
    of the codebase we always use the first product image (product.image[0])
    in case the variant image doesn't exist.
2. Lets do that here too. We can also prefer the thumbnail image because
    its smaller and we don't need a large image. If that doesn't exist
    either lets fall back to the default product image.
3. The product image isn't garunteed to exist either, but if it doesn't
    that means there is no image associated with the product.
  • Loading branch information
aburke07 committed Jun 30, 2023
1 parent ae894a5 commit f14fbb8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion frontend/templates/troubleshooting/Resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export function ProductResource({ product }: { product: Product }) {
<Resource
href={productUrl}
title={product.title}
imageUrl={selectedVariant.image?.url}
imageUrl={
selectedVariant.image?.url ||
product.images[0]?.thumbnailUrl ||
product.images[0]?.url
}
spacing="4px"
showBuyButton={isForSale}
openInNewTab={true}
Expand Down

0 comments on commit f14fbb8

Please sign in to comment.