Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Created February 12, 2014 14:29
Show Gist options
  • Select an option

  • Save msmithstubbs/8956515 to your computer and use it in GitHub Desktop.

Select an option

Save msmithstubbs/8956515 to your computer and use it in GitHub Desktop.
Match image in the email template to the variant.
{% comment %}
This looks for an image with the same alt text as the variant title.
You can use this if your are matching variants to images using the image ALT text.
{% endcomment %}
{% assign main_image = product.featured_image %}
{% for image in product.images %}
{% if image.alt == variant.title %}
{% assign main_image = image %}
{% endif %}
{% endfor %}
@msmithstubbs
Copy link
Author

Installation

  1. Add this to the top of your email template.
  2. Replace product.featured_image.url with main_image.url
  3. Save the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment