From 2d12361b0ab85212cc6bd50d8fdf5392e04196f4 Mon Sep 17 00:00:00 2001 From: Kyle <41976328+ImKyle4815@users.noreply.github.com> Date: Wed, 13 Oct 2021 20:26:28 -0700 Subject: [PATCH] Update creator-23.js --- js/creator-23.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/js/creator-23.js b/js/creator-23.js index a9bcba8f..621bfb80 100644 --- a/js/creator-23.js +++ b/js/creator-23.js @@ -1260,10 +1260,27 @@ function artFromScryfall(scryfallResponse) { function changeArtIndex() { const artIndexValue = document.querySelector('#art-index').value; if (artIndexValue != 0 || artIndexValue == '0') { - uploadArt(scryfallArt[artIndexValue].image_uris.art_crop, 'autoFit'); - artistEdited(scryfallArt[artIndexValue].artist); + const scryfallCardForArt = scryfallArt[artIndexValue]; + uploadArt(scryfallCardForArt.image_uris.art_crop, 'autoFit'); + artistEdited(scryfallCardForArt.artist); + if (params.get('mtgpics') == 'true') { + imageURL(`https://www.mtgpics.com/pics/art/${scryfallCardForArt.set.toLowerCase()}/${("00" + scryfallCardForArt.collector_number).slice(-3)}.jpg`, tryMTGPicsArt); + } } } +function tryMTGPicsArt(src) { + var attemptedImage = new Image(); + attemptedImage.onload = function() { + if (this.complete) { + art.onload = function() { + autoFitArt(); + art.onload = artEdited; + }; + art.src = this.src; + } + } + attemptedImage.src = src; +} function initDraggableArt() { previewCanvas.onmousedown = artStartDrag; previewCanvas.onmousemove = artDrag;