How to use with image croppers? #434
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi!
How to use with image croppers like this:
https://github.com/cstefanache/angular2-img-cropper
Hi kolkov,
It is pretty simple with angular2-img-cropper
Did anyone get this working?
onAfterAddingFile only seems to call after onCompleteItemCallback
and readAsDataURL needs a blob not a file.
any help appreciated.
Anyone has solution for this?
<ion-row > <ion-col *ngIf="!organization.imageName"> <img-cropper #cropper [image]="data1" [settings]="cropperSettings"></img-cropper> <br> <!-- <span class="result rounded" *ngIf="data1.image" > <img [src]="data1.image" [width]="cropperSettings.croppedWidth" [height]="cropperSettings.croppedHeight"> </span> --> <ion-button size="small" (click)="uploadAll(data1.image)" >upload</ion-button> </ion-col> </ion-row>`uploadAll(image){
console.log('func call',image);
this.croppedImage=image;
this.uploader.uploadAll();
}
upload() {
var image;//file upload methods
this.uploader.onAfterAddingFile = (item) => {
console.info('After adding a file', item,this.data1);
this.image = new Image();
var fileReader: FileReader = new FileReader();
var that = this;
fileReader.onloadend = function (loadEvent: any) {
that.image.src = loadEvent.target.result;
that.cropper.setImage(that.image);
console.log(that.data1);
};
fileReader.readAsDataURL(item._file);
};
this.uploader.onBeforeUploadItem=(item:any)=>{
}`
I would like to share my solution.
Hope this will help!