From 80a410587476b2a5a6bba3a8b95c3218464cc4ab Mon Sep 17 00:00:00 2001 From: "d.malygin" Date: Fri, 16 Aug 2024 16:09:02 +0500 Subject: [PATCH] change url of image and cropper --- src/components/CreateEntityMenu.vue | 26 ++++++++++-------------- src/modules/BaseModal.vue | 8 +++++++- src/pages/HomePage.vue | 31 ++++++++++++----------------- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/components/CreateEntityMenu.vue b/src/components/CreateEntityMenu.vue index 63759b7..6dbdd34 100644 --- a/src/components/CreateEntityMenu.vue +++ b/src/components/CreateEntityMenu.vue @@ -15,25 +15,19 @@ const { }); const addImage = (files: FileList) => { - console.log('files', files); let image = new Image(); - const file = files[0]; - const reader = new FileReader(); console.log('file', file, 'type: ', typeof file); - reader.readAsDataURL(file); - reader.addEventListener('load', () => { - const url = reader.result; - image.src = url; - console.log('image width and height: ', image.width, image.height); - console.log('url length: ', url.length); - emit('addEntity', { - entity_type: 'image', - entity_uuid: uuidv4(), - image_data: url, - image_position: 'left', - image_height: 300 - }); + const url = URL.createObjectURL(file); + image.src = url; + console.log('image width and height: ', image.width, image.height); + console.log('url length: ', url.length); + emit('addEntity', { + entity_type: 'image', + entity_uuid: uuidv4(), + image_data: url, + image_position: 'left', + image_height: 300 }); }; onChange((files) => { diff --git a/src/modules/BaseModal.vue b/src/modules/BaseModal.vue index 3e192ba..af212bf 100644 --- a/src/modules/BaseModal.vue +++ b/src/modules/BaseModal.vue @@ -1,6 +1,7 @@ @@ -96,7 +90,8 @@ function uploadFile($event: Event) { title="Change image" accept="image/*" class="w-2 pr-[135px] -mr-[135px] py-2 -my-2 pl-2 -ml-2 opacity-0" - />Change image + /> + Change image