cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

Image cropper with src #203

Open kenadet opened 7 years ago

kenadet commented 7 years ago

Can image cropper have an src attribute , so we can set default image or background?

ClaudioKirchmair commented 6 years ago

Here is what I use to set the cropperImage default image (maybe this helps you). This example works with an image url (eg. https://test.at/test.jpg).

` @ViewChild('imageCropper', undefined) imageCropper: ImageCropperComponent;

ngAfterViewInit() { let image: HTMLImageElement = new Image(); // lets you use the parent scope (of your Component) let that = this; image.onload = function() { that.imageCropper.setImage(image); }; // fires onload function image.src = imageUrl; // your default imageUrl } `

kenadet commented 6 years ago

Appreciate.