fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper
MIT License
7.76k stars 1.74k forks source link

change minCropBoxWidth/Height programmatically #208

Closed dark-cms closed 9 years ago

dark-cms commented 9 years ago

I use the Cropper for a Mediaeditor.

Based on some Extensions it should be possible to "pre"-resize the Image (Points of interest and so on), but i am missing the feature to set minCropBoxWidth and Height after loading another ratio.

As Example: Image-Setup 1 scales Images to 800x600px, so the cropbox should not be lower than this values. Image-Setup 2 scales Images to 250x400px, so the cropbox should not be lower than this values.

This works fine with radio buttons

var selection = $( ".ratiobuttons:checked");
var data = selection.data();
$('.imagecropper >img').cropper('setAspectRatio',data.width / data.height);

but is it possible to change the min-values of Crop?

something like

$('.imagecropper >img').cropper('setMinCrop',{width: data.width,height: data.height});
fengyuanchen commented 9 years ago
var $image = $('#myImage').cropper(), // Initialize
    cropper = $image.data('cropper'), // Get the instance
    cropBox = cropper.cropBox; // Get the crop box object

...
cropBox.minWidth = 160; // Set a new minimum width
cropBox.minWidth = 90; // Set a new minimum height
...