You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Related to frontvibe#366
Update `MediaGallery` component to display both product and variant images, prioritizing the selected variant's images.
* Import `useProductVariants` and `useSelectedVariant` hooks in `app/components/product/MediaGallery.tsx`.
* Concatenate variant images with product images and remove duplicate images based on Shopify CDN file URL.
* Modify `useSelectedVariant` hook in `app/hooks/useSelectedVariant.tsx` to include `images` field for the selected variant.
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:
useProductVariants()
anduseSelectedVariant()
hooks to access variant data.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.
The text was updated successfully, but these errors were encountered: