Skip to content

Add variant-based media grouping for product pages#347

Merged
hta218 merged 12 commits intodevfrom
feat/variant-media-grouping
Mar 4, 2026
Merged

Add variant-based media grouping for product pages#347
hta218 merged 12 commits intodevfrom
feat/variant-media-grouping

Conversation

@hta218
Copy link
Member

@hta218 hta218 commented Mar 3, 2026

Summary

  • Adds opt-in feature to filter product media by selected variant option (e.g., Color)
  • When enabled, only images matching the selected option value in the filename are displayed
  • Shared/ungrouped media (lifestyle shots, videos, etc.) is always appended after matched images
  • Graceful fallback to showing all media when no variant images are assigned

Changes

  • New: app/utils/variant-media.ts — Pure utility with getVariantGroupedMedia() for filename-based variant image matching
  • Modified: app/components/product/product-media.tsx — Added groupMediaByVariant, groupByOption, and product props
  • Modified: app/sections/main-product/index.tsx — Added Weaverse schema settings for the feature
  • Modified: app/sections/single-product/index.tsx — Same schema settings and prop passing

Weaverse Settings

Setting Type Default Description
Group media by variant Switch Off Toggle to enable variant-based media filtering
Group by option name Text "Color" The product option name that drives grouping

When enabled via Weaverse section settings, filters product media to show
only images matching the selected variant option (e.g., Color). Uses
variant.image URL matching with graceful fallback to all media when no
matches found. Shared/ungrouped media is always appended after matched.
@Weaverse Weaverse deleted a comment from changeset-bot bot Mar 3, 2026
…iants

adjacentVariants only returns variants adjacent to the current selection,
not all product variants. Added variants(first: 100) to PRODUCT_QUERY to
fetch all variants with their images for proper grouping.
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: 6c051a5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

hta218 added 10 commits March 4, 2026 05:40
- Group images by option value (lowercase) into a map
- Match selected option value against the group
- Ungrouped media = images not matching ANY variant (shared)
- Media matching other option values are excluded (not shown)
- Re-runs on every variant change
variant.image is 1:1 in Shopify (one image per variant), so URL matching
only finds 1 image per color. Now extracts option value from filename
(e.g., '24b_xxx_black.jpg' → 'black') to group multiple images per color.
…5.7.0 to 2026.1.0 with detailed migration steps and new features
The variant media grouping feature uses filename-based matching,
not variant.image URLs, so this query field was dead weight.
@hta218 hta218 merged commit c87b436 into dev Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant