diff --git a/components/GalleryImageViewer.vue b/components/GalleryImageViewer.vue index 00dd3b9..757834b 100644 --- a/components/GalleryImageViewer.vue +++ b/components/GalleryImageViewer.vue @@ -31,11 +31,13 @@ diff --git a/mixins/imageLoader.js b/mixins/imageLoader.js new file mode 100644 index 0000000..1c118be --- /dev/null +++ b/mixins/imageLoader.js @@ -0,0 +1,16 @@ +export default { + methods: { + loadImage(url) { + return new Promise( (resolve, reject) => { + const img = new Image() + + img.addEventListener('load', e => resolve(img)); + img.addEventListener('error', () => { + reject(new Error(`Failed to load image URL: ${url}`)); + }); + + img.src = url; + }) + } + } +}