Skip to content

Displaying selected variant images alongside product images? #366

@pycxu

Description

@pycxu

Hi, I'm pretty new to Shopify and Hydrogen.

I am trying to figure out the best approach for MediaGallery to display both product and variant images, while prioritising the selected variant's images in the gallery:

  • Utilise the useProductVariants() and useSelectedVariant() hooks to access variant data.
  • Convert variant images to MediaImage and concatenate them with the product images (MediaImage), while ensuring that duplicate images are removed based on their Shopify CDN file url. This is necessary since variant and product images may have different IDs? (gid://shopify/ProductImage/* vs. gid://shopify/ImageSource/*), but the URLs are identical for the same image.

Not too sure about this, any suggestions?

Thank you.

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