advanced-cropper / vue-advanced-cropper

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design
https://advanced-cropper.github.io/vue-advanced-cropper/
Other
930 stars 128 forks source link

Question: Is there a way to pass uploaded files to the cropper component? #232

Closed jaredmeakin closed 1 year ago

jaredmeakin commented 1 year ago

So, I have an <input /> that I'm trying to upload a photo to. I want to pass that file to the <cropper /> component, but that doesn't seem to work. Is there a way to accomplish what I'm trying to do?

<app-input
  v-model="photo"
  class="mb-5"
  name="photo"
  type="file"
  accept="image/png, image/jpeg"
  placeholder="Upload a photo"
  @change="onPhotoUpload"
/>
<cropper class="cropper" :src="photo" :stencil-props="{ aspectRatio: 10 / 12 }" />
const photo = ref();

function onPhotoUpload(e) {
  photo.value = e.target.value;
}
Norserium commented 1 year ago

@jaredmeakin, did you try the approach from the "load image from a disc" guide?

jaredmeakin commented 1 year ago

Thanks that should work!