javascript - How to carry an image across different files? -
okay carry image across file b file a. when upload image (in code 'b') using upload button displays "blah" , "blah2" need display in/where code <img src="{{ image.src | img_url: 'compact' }}" alt="{{ image.alt | escape }}">
(in code 'b') , says <img src="{{ item | img_url: 'medium' }}" alt="{{ item.title | escape }}">
(in code a) don't understand how transfer code over/call code "code b" "code a"? suggestions , extremely/unbelievably appreciated i've been trying figure out week , have got no where....... thank looking!
code a:
<!-- bold: options 4-5 --> {% if builder[0] %} <img src="{{ builder[1] }}" alt="{{ builder[0] }}" /> {% else %} <img src="{{ item | img_url: 'medium' }}" alt="{{ item.title | escape }}"> </a> <!-- bold: options 4-6 --> {% include 'boldoptions' 'step6' %} <!-- // end options 4-6 --> {% endif %} <!-- // end options 4-5 -->
code b:
<form id="form1" runat="server"> <input type='file' id="imginp" /> <br> <img id="blah" src="" alt="upload image" /> <img id="blah2" src="" alt="upload image" /> <img id="grooved" src="https://lh3.googleusercontent.com/-6wxp99pr7hu/vpa-nidksdi/aaaaaaaamka/r59f0in-yya/s800-ic42/grooved%252520view%252520for%252520shopify.png" alt="your image" height="100" /> </form> <br/> <div id="nofileerror" style="display:none;"> <b>please select valid image file.</b> </div> <button id="checkimage" style="display:none;"> check image </button> <br/> <b>resolution check result: </b> <p>if nothing displayed underneath means image top quality , ready printing!</p> <p> </p> <div id="imagevalidationerror" style="display:none;"> <b id="lr">unfortunatley image resolution low our pixboards, may still proceed using image cannot guarentee great resolution! proceeding image you're agreeing , aknowladge resolution not high standards advertised.</b> </div> <style> #lr { color: red; } ::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.2); background-color: #f5f5f5; } ::-webkit-scrollbar { width: 6px; background-color: #f5f5f5; } ::-webkit-scrollbar-thumb { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.2); background-color: #555; } #blah { width:550px; height:550px; background-image: url('path/to/image'); background-position: center; background-size: cover; } #blah2 { width:550px; height:550px; background-image: url('path/to/image'); background-position: center; background-size: cover; position: absolute; } #grooved { width: 550px; height: 550px; position: absolute; top: auto 0; } </style> <script> function readurl(input) { if (input.files && input.files[0]) { var reader = new filereader(); reader.onload = function (e) { $('#blah').attr('src', e.target.result); } reader.readasdataurl(input.files[0]); isgoodimage(input.files[0]) } } $("#imginp").change(function(){ readurl(this); }); function readurl2(input) { if (input.files && input.files[0]) { var reader = new filereader(); reader.onload = function (e) { $('#blah2').attr('src', e.target.result); } reader.readasdataurl(input.files[0]); } } $("#imginp").change(function(){ readurl2(this); }); var _url = window.url || window.webkiturl; function issupportedbrowser() { return window.file && window.filereader && window.filelist && window.image; } function getselectedfile() { var fileinput = document.getelementbyid("imginp"); var fileisselected = fileinput && fileinput.files && fileinput.files[0]; if (fileisselected) return fileinput.files[0]; else return false; } function isgoodimage(file) { var deferred = jquery.deferred(); var image = new image(); image.onload = function() { // check if image bad/invalid if (this.width + this.height === 0) { this.onerror(); return; } // check image resolution if (this.width >= 3000 && this.height >= 2000) { deferred.resolve(true); } else { $("#imagevalidationerror").show(); deferred.resolve(false); } }; image.onerror = function() { $("#nofileerror").show(); deferred.resolve(false); } image.src = _url.createobjecturl(file); return deferred.promise(); } /** new code **/ $("#checkimage").click(function(){ if (issupportedbrowser()) { var file = getselectedfile(); if (!file) { $("#nofileerror").show(); return; } isgoodimage(file) } }) </script>
<div class="product-single"> <div class="grid product-single__hero"> <div class="grid__item large--one-half"> <div class="product-single__photos" id="productphoto"> {% assign featured_image = product.selected_or_first_available_variant.featured_image | default: product.featured_image %} <img src="{{ featured_image | img_url: '1024x1024' }}" alt="{{ featured_image.alt | escape }}" id="productphotoimg"{% if settings.product_image_zoom_enable %} data-zoom="{{ featured_image | img_url: '1024x1024' }}"{% endif %}> </div> </div>
Comments
Post a Comment