Skip to content

Primary image fallback #205

@buuhuu

Description

@buuhuu

Currently we rely on a image with role image to be present as primary image for the ld+json entry and the page metadata:

const primaryImage = getPrimaryImage(baseProduct)?.url;
templateProductData.hasImages = baseProduct.images?.length > 0;
templateProductData.imageList = getImageList(primaryImage, baseProduct.images);
templateProductData.priceString = generatePriceString(baseProduct);
templateProductData.metaDescription = findDescription(baseProduct);
templateProductData.metaImage = primaryImage;
templateProductData.primaryImage = primaryImage;

and

const { name, sku, __typename } = product;
const image = getPrimaryImage(product);
const url = getProductUrl(product, context);

The logic currently has no fallback, meaning there will be a ld+json with a missing image, which is invalid for a merchant listing.

One option would be to fallback to the first image, if there is none for the given role.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions