【发布时间】:2015-07-15 02:40:52
【问题描述】:
我正在尝试使用 fengyuanchen jquery cropper 插件 - https://github.com/fengyuanchen/cropper 强制裁剪数据输出的最小大小
插件提供minCropBoxWidth 和minCropBoxHeight 两个选项,但这些选项仅控制屏幕上的实际裁剪框。由于裁剪器中的图像大小可以是任意的(在合理范围内),这无助于确保最终输出的大小。它可以直接检索图像的实际大小(它在数据参数中传递给crop 函数)。我坚持的是,一旦满足最小宽度/高度值,就停止裁剪框的尺寸减小。我得到$(this).cropper(...).disable is not a function
$('.image-preview img').cropper({
aspectRatio:1/1,
strict:true,
background:false,
guides:false,
autoCropArea:1,
rotatable:false,
minCropBoxWidth:20,//using these just to stop box collapsing on itself
minCropBoxHeight:20,
crop:function(data){
//test the new height/width
if(data.height < 120 || data.width < 120){
//try to make it stop
$(this).cropper().disable(); //here be the error
}else{
var json = [
'{"x":' + data.x,
'"y":' + data.y,
'"height":' + data.height,
'"width":' + data.width + '}'
].join();
$('#image-data').val(json);
}
}
【问题讨论】:
标签: php jquery image-processing jquery-plugins