You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<scriptsrc="/path/to/jquery.js"></script><!-- jQuery is required --><scriptsrc="/path/to/cropper.js"></script><!-- Cropper.js is required --><linkhref="/path/to/cropper.css" rel="stylesheet"><scriptsrc="/path/to/jquery-cropper.js"></script>
Usage
Initialize with $.fn.cropper method.
<!-- Wrap the image or canvas element with a block element (container) --><div><imgid="image" src="picture.jpg"></div>
/* Limit image width to avoid overflow the container */img {
max-width:100%; /* This rule is very important, please do not ignore this! */
}
var$image=$('#image');$image.cropper({aspectRatio: 16/9,crop: function(event){console.log(event.detail.x);console.log(event.detail.y);console.log(event.detail.width);console.log(event.detail.height);console.log(event.detail.rotate);console.log(event.detail.scaleX);console.log(event.detail.scaleY);}});// Get the Cropper.js instance after initializedvarcropper=$image.data('cropper');
If you have to use other plugin with the same namespace, just call the $.fn.cropper.noConflict method to revert to it.
<scriptsrc="other-plugin.js"></script><scriptsrc="jquery-cropper.js"></script><script>$.fn.cropper.noConflict();// Code that uses other plugin's "$().cropper" can follow here.</script>