bold-e of Professional Services
5/19/2015 - 3:10 PM

Product Option Image Upload Changes image.

Product Option Image Upload Changes image.

 {% assign uploadedImage = false %}
    {% for p in item.properties %}
      {% if p.last contains '/uploads/' %}
    	{% assign uploadedImage = true %}
    	{% assign imageURL = p.last %}
      {% endif %}
    {% endfor %}
      {% if item.product.images.size > 0 %}
    	   {% if uploadedImage %}
            <img src="{{imageURL}}" alt="Uploaded Image" />
          {% elsif builder[0] %}
    		  <img src="{{ builder[1] }}" alt="{{ builder[0] }}" />
    		{% else %}
   		    {{ item | img_url: 'small' | img_tag }}
    	  {% endif %}
    {% else %}
      	{% if uploadedImage %}
         <img src="{{imageURL}}" alt="Uploaded Image" />
      	{% else %}
          <img class="product-no-images" src="{{ 'no-image.svg' | asset_url }}" alt="No Image Available" />
    	  {% endif %}
    {% endif %}
//show image on after upload
  
  function readURL(input) {

    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
          //may need to change based on how image is displayed in theme
            $('.product-big-image img').attr('src', e.target.result);
            $('.product-big-image img').attr('alt', "Uploaded Image");
        }

        reader.readAsDataURL(input.files[0]);
    }
}

  $("div.shappify_option_value input:file").change(function(){
    readURL(this);
});