Customization options — Digital File (Single High-Res Image)
-
Proof Number
(required)
(e.g. ROW-25-MB-001)
imgH) ? maxDim / imgW : maxDim / imgH; var w = imgW * scale; var h = imgH * scale; ctx.drawImage(img, (canvas.width - w) / 2, (canvas.height - h) / 2, w, h); setTimeout(function () { stage.toImage({ callback: function (kimg) { try { ctx.drawImage(kimg, 0, 0, canvas.width, canvas.height); } catch (_) {} cb(canvas.toDataURL("image/jpeg", 0.7)); } }); }, 250); }; img.onerror = function () { stage.toImage({ callback: function (kimg) { cb(kimg && kimg.src || null); } }); }; img.src = imageUrl; } else { stage.toImage({ callback: function (kimg) { cb(kimg && kimg.src || null); } }); } } catch (e) { cb(null); } } function storeThumb(thumb) { if (!photoId || !thumb || typeof thumb !== "string") return false; if (!(thumb.indexOf("data:image") === 0 && thumb.length > MIN_THUMB_LEN)) return false; try { sessionStorage.setItem("jet_thumb_" + photoId, thumb); } catch (_) {} return true; } // ===== PRE-CAPTURE ===== (function precaptureLoop(i) { if (i > PRECAPTURE_TRIES) return; capture(function (d) { if (storeThumb(d)) return; setTimeout(function () { precaptureLoop(i + 1); }, PRECAPTURE_GAP); }); })(1); // ===== ENSURE LINE-ITEM PROPERTIES ===== function ensureProps(form) { function setHidden(name, value) { var sel = "input[name=\"properties[" + name + "]\"]"; var el = form.querySelector(sel); if (!el) { el = document.createElement("input"); el.type = "hidden"; el.name = "properties[" + name + "]"; form.appendChild(el); } el.value = value || ""; } setHidden("_thumbnail_id", photoId); setHidden("_Proof number", photoId); if (imageUrl && imageUrl !== FALLBACK_IMAGE) { setHidden("_customer_photo", imageUrl); } if (photoId && imageUrl && imageUrl !== FALLBACK_IMAGE) { var productUrl = window.location.pathname + "?photo_id=" + safeEncode(photoId) + "&customer_image=" + safeEncode(imageUrl); setHidden("_product_url", productUrl); } } // ===== SUBMIT HOOK ===== function hookForms() { document.querySelectorAll("form[action*=\"/cart/add\"]").forEach(function (form) { if (form.dataset.jetDigitalHooked === "1") return; form.dataset.jetDigitalHooked = "1"; form.addEventListener("submit", function onSubmit(e) { if (window.__JET_ADD_IN_PROGRESS) { e.preventDefault(); e.stopImmediatePropagation(); return; } window.__JET_ADD_IN_PROGRESS = true; e.preventDefault(); e.stopImmediatePropagation(); capture(function (thumb) { storeThumb(thumb); ensureProps(form); try { HTMLFormElement.prototype.submit.call(form); } finally { window.__JET_ADD_IN_PROGRESS = false; } }); }, { capture: true }); }); } setTimeout(hookForms, 300); setTimeout(hookForms, 900); setTimeout(hookForms, 1800); } catch (err) { console && console.error && console.error("[JET Digital v2.5] Error", err); } })(); '>
containerRatio){ // Image is wider than container - fit to width bgWidth = containerW; bgHeight = containerW / imgRatio; } else { // Image is taller than container - fit to height bgHeight = containerH; bgWidth = containerH * imgRatio; } // Center the image bgX = (containerW - bgWidth) / 2; bgY = (containerH - bgHeight) / 2; return { width: bgWidth, height: bgHeight, x: bgX, y: bgY }; } var attempts = 0; var maxAttempts = 120; var checkInterval = setInterval(function(){ attempts++; var canvas = getSceneCanvas(); if(!canvas || canvas.width window.innerWidth){ magDiv.style.left = (evt.clientX - size - offset) + 'px'; } if(rect.bottom > window.innerHeight){ magDiv.style.top = (evt.clientY - size - offset) + 'px'; } // USE HOST RECT for background calculations (not canvas rect) var hostRect = hostElement.getBoundingClientRect(); var mouseX = evt.clientX - hostRect.left; var mouseY = evt.clientY - hostRect.top; var sourceSize = size / zoom; var sourceX = mouseX - sourceSize / 2; var sourceY = mouseY - sourceSize / 2; ctx.clearRect(0, 0, size, size); ctx.fillStyle = '#f0f0f0'; ctx.fillRect(0, 0, size, size); try{ if(bgImg && bgReady && bgImg.complete && bgImg.naturalWidth > 0){ // Get current background size mode var currentBgSize = window.getComputedStyle(hostElement).backgroundSize; var bgDims; if(currentBgSize === 'contain'){ // Use contain calculation with HOST dimensions bgDims = calcContainDimensions( hostRect.width, hostRect.height, bgImg.naturalWidth, bgImg.naturalHeight ); } else { // Fallback to percentage-based calculation var bgSizeVal = parseFloat(currentBgSize); if(isNaN(bgSizeVal)) bgSizeVal = 85; var scale = bgSizeVal / 100; var bgWidth = hostRect.width * scale; var bgHeight = (bgImg.naturalHeight / bgImg.naturalWidth) * bgWidth; var bgX = (hostRect.width - bgWidth) / 2; var bgY = (hostRect.height - bgHeight) / 2; bgDims = { width: bgWidth, height: bgHeight, x: bgX, y: bgY }; } var scaleX = bgDims.width / bgImg.naturalWidth; var scaleY = bgDims.height / bgImg.naturalHeight; var imgSourceX = (sourceX - bgDims.x) / scaleX; var imgSourceY = (sourceY - bgDims.y) / scaleY; var imgSourceSizeX = sourceSize / scaleX; var imgSourceSizeY = sourceSize / scaleY; ctx.drawImage(bgImg, imgSourceX, imgSourceY, imgSourceSizeX, imgSourceSizeY, 0, 0, size, size); } // Draw Konva overlay (still use canvas for this) var canvasRect = canvas.getBoundingClientRect(); var canvasMouseX = evt.clientX - canvasRect.left; var canvasMouseY = evt.clientY - canvasRect.top; var canvasSourceX = canvasMouseX - sourceSize / 2; var canvasSourceY = canvasMouseY - sourceSize / 2; ctx.drawImage(canvas, canvasSourceX, canvasSourceY, sourceSize, sourceSize, 0, 0, size, size); }catch(err){ console.log('[MAG v1.6.1] Draw error:', err); } }); console.log('[MAG v1.6.1] Ready'); }, 100); }, 2000); })(); ">