Search Posts

Category: cropperjs

Cross origin issue with cropper.js

I am using cropper.js to crop the images I wrote a directive which will take the image src return { restrict: ‘A’, controller: _cropperController, bindToController: { imagesrc:”=?” }, link:function($scope, $element, $attrs, ctrl){ var img = document.createElement(“img”); img.src = ctrl.imagesrc; img.id=’image’; document.getElementsByTagName(“body”)[0].appendChild(img); Cropper.setDefaults({ checkCrossOrigin: false }); var cropper = new Cropper(img, { aspectRatio: 1 / 1, checkCrossOrigin: false, crop: function(e) { console.log(e.detail.x); console.log(e.detail.y); } }); if(cropper.getCroppedCanvas()){ var imgurl = cropper.getCroppedCanvas().toDataURL(); ctrl.imagesrc= imgurl; } } }; Then […]