Assign multiple images to single variant

The docs at productVariantAppendMedia - GraphQL Admin suggest that a single product variant can accept multiple mediaIds (the input is an array), but this fails with error ““Only one mediaId is allowed per media input.”. Is there any intention to be able to attach multiple variant images to a given variant?

1 Like

Hi @Paul_Holmes,

This is correct that you can currently only attach a single product image to a variant at this time. The variantMedia input argument on the productVariantAppendMedia mutation is an array in order to accept multiple image/variant pairs in a single mutation.

For example, say I have a product id: 123, and I have two variants on that product, with variant ids; 456, and 789. I can attach media to both of these variants with a single call like so:

{
  "productId": "gid://shopify/Product/123",
  "variantMedia": [
    {
      "mediaIds": [
        "gid://shopify/MediaImage/111"
      ],
      "variantId": "gid://shopify/ProductVariant/456"
    },
    {
      "mediaIds": [
        "gid://shopify/MediaImage/222"
      ],
      "variantId": "gid://shopify/ProductVariant/789"
    }
  ]
}

I will definitely be submitting some feedback internally on your behalf that you’d like to see the ability to attach multiple media files to individual variants, and I would recommend that you submit some feedback on this as well. You can do so by scrolling to the bottom of the page in the Shopify.dev documentation and selecting Was this section helpful?: No, and enter your custom feedback.

Hi @Kellan-Shopify @Paul_Holmes

I came across the following statement in the documentation about the productVariantAppendMedia GraphQL mutation:

“Currently, only one mediaId is allowed per variant in the mutation, even though the variantMedia input is an array allowing multiple image/variant pairs in a single call.”

While it’s clear that right now we can only assign one image per variant, I wanted to follow up on this and ask:

  1. Are there any plans to allow multiple images for a single product variant in the future?

  2. If not, what would be the best workaround to achieve a similar effect? Is it possible to manage this by using additional product media, or perhaps create multiple variants for the same product with different images (for example, one variant for each image)?

  3. Are there any other advanced options or techniques to manage multiple images per variant that aren’t explicitly covered in the current documentation?

I believe this feature could be really useful for showcasing multiple angles, colors, or details of a single variant and would greatly appreciate any suggestions, or workarounds you may have!

Looking forward to your response!

@OMAR_OUAISSI_SEKOUTI The most common approach is to use variant level metafields to store a set of additional media (images/video). That way both stores and custom themes have full control. However, I do agree that it’s overdue for Shopify to support multiple media items per variant. In 10 years of premium theme support, this continues to be one of the most common requests merchants ask about.

Hi @OMAR_OUAISSI_SEKOUTI and @Paul_Holmes,

I can confirm that Paul is correct here, the best workaround for this limitation would be to store the images as a file_reference metafield on the product variant as the metafield owner.

Here’s some Shopify.dev documentation to help get started with managing metafields. Once you’ve created the metafields, they can be used on the Storefront via the metafields field on the variant Liquid object.

I do understand that this is a commonly requested feature, and I will be submitting some feedback regarding this from both of you as well, as the more requests we get for features like these the more likely and sooner they would be added, as our developers and product managers do take all of our Partner and Merchant feedback into great value when determining future features and updates to the platform.