I use the "cropper" https://github.com/fengyuanchen/cropper
I choose an image for cropper:
var image = $('#cropper > img'); I get the default data from the hidden input'a:
var cropData = $("#params").val(); I initialize the cropper myself:
image.cropper({ aspectRatio: 1, autoCropArea: 0.65, zoomable: false, minCropBoxWidth: 50, minCropBoxHeight: 50, data: cropData, }); The data parameter does not receive data from cropData , but if you specify something like:
data: {"x":420.84485791610285,"y":100.70209742895806,"width":349.70000000000005,"height":349.70000000000005,"rotate":0}, That all works.
Conclusion:
console.log(cropData) {"x":420.84485791610285,"y":100.70209742895806,"width":349.70000000000005,"height":349.70000000000005,"rotate":0}, Help to set the parameter correctly ... In JS and jQuery, it is never strong. Thank.