Add Image Attr PDD

Demo site marktdiscount 
product-variant-options line 80
 {%- elsif picker_type == 'button' -%}
{% assign option_index = 0 %}
{% for option in product.options_with_values %}
  {% if option.name == 'Farbe' or option.name == 'Color' %}
    {% assign option_index = forloop.index0 %}
  {% endif %}
{% endfor %}

{% assign shown_values = '' %}

{% for variant in product.variants %}
  {% case option_index %}
    {% when 0 %}{% assign value = variant.option1 %}
    {% when 1 %}{% assign value = variant.option2 %}
    {% when 2 %}{% assign value = variant.option3 %}
  {% endcase %}

  {% unless shown_values contains value %}
    {% assign shown_values = shown_values | append: value | append: ',' %}

    {%- assign image_url = '' -%}

    {%- for v in product.variants -%}
      {% case option_index %}
        {% when 0 %}{% assign v_value = v.option1 %}
        {% when 1 %}{% assign v_value = v.option2 %}
        {% when 2 %}{% assign v_value = v.option3 %}
      {% endcase %}
      {% if v_value == value and v.featured_image %}
        {% assign image_url = v.featured_image | img_url: 'master' %}
        {% break %}
      {% endif %}
    {%- endfor -%}

    <input
      type="radio"
      id="{{ value | handleize }}"
      name="{{ input_name | escape }}"
      value="{{ value | escape }}"
      form="{{ product_form_id }}"
      {% if value == option.selected_value %}
        checked
      {% endif %}
      {{ input_dataset }}
    >

  <label for="{{ value | handleize }}" class="color-label{% if image_url != '' %} image-custom{% endif %}">
      {% if image_url != '' %}
        <img src="{{ image_url }}" alt="{{ value }}">
      {% endif %}
      <span>{{ value }}{{ label_unavailable }}</span>
    </label>

  {% endunless %}

  {%- elsif picker_type == 'dropdown' or picker_type == 'swatch_dropdown' -%}

Leave a Reply

Your email address will not be published. Required fields are marked *