Add an image preview to the order confirmation emails

Follow the steps below on how to display an image preview in your order confirmation emails.

1. Starting from your Shopify admin dashboard, navigate to the Settings tab, then click on Notifications

2. Click on the link for the Order Confirmation email.

3. Search for this line of code.

 {% if line.variant.title != 'Default Title' %}

4. Copy and paste the following code snippet in the specified location. 

{% for p in line.properties %}
  {% if p.first contains '_io_' %}
    {% continue %}
  {% endif %}
  {% if p.last %}
    {% assign name = p.first %}
    {% assign value = p.last %}
  {% else %}
    {% assign name = p.name %}
    {% assign value = p.value %}
  {% endif %}
  {% unless value == blank %}
    <p style='margin-top: 0px; margin-bottom: 0px; font-size: 14px; color: #999;'>
      <br />{{ name }}:
    {% if p.last contains '//uploadery.s3' %}
      {% if p.last contains '.png' or p.last contains '.jpg' or p.last contains '.jpeg' or p.last contains '.gif' %}
         {% assign file_parts = p.last | split:"/" %}
         {% assign file_path = file_parts | last %}
         {% assign file_parts = file_parts | join: "/" | replace: file_path, "" %}
         {% assign preview_image = file_parts | append: "preview_" | append: file_path %}
     {% endif %}
     {% if preview_image %}
         <img src="{{ preview_image }}" alt="{{ item.title | escape }}" style='height: 50px; width: 50px; float:left; border-radius: 3px; margin-right: 5px; object-fit: cover;'>
       {% assign preview_image = false %}
      <br /><a style='font-size: 14px;' href="{{ value }}">Link to your file</a>
      {% endif %}
    {% else %}
      {{ value }}
    {% endif %}
    </p>
  {% endunless %}
{% endfor %}
	

5. Save your changes.