jQuery cropit 插件检查当前图像是否可缩放
jQuery cropit plugin check if current image is zoomable
我用这个插件裁剪图片:http://scottcheng.github.io/cropit/
我想知道如何找出当前图像是否可以缩放,这样我就可以隐藏缩放 div 如果不是,它说这个功能就是为了它: $imageCropper.cropit('isZoomable');
但是如何使用它?我是 jQuery 的初学者。
到目前为止,这是我的代码:
$(function() {
$('.image-editor').cropit({ imageBackground: true, imageBackgroundBorderWidth: 15 });
if ($('.image-editor').cropit('isZoomable')) {
alert("you can zoom");
} // EDIT: I added it but it's not working
$('form').submit(function() {
// Move cropped image data to hidden input
var imageData = $('.image-editor').cropit('export', {
type: 'image/jpeg',
quality: .9
});
$('.hidden-image-data').val(imageData);
// Print HTTP request params
var formValue = $(this).serialize();
$.ajax({
type: 'post',
url: 'doupload.php',
data: {bilddata: formValue},
success: function(data) {
}
});
return false;
});
})
就是这样:
if ($('.image-editor').cropit('isZoomable')) {
// code
}
我用这个插件裁剪图片:http://scottcheng.github.io/cropit/
我想知道如何找出当前图像是否可以缩放,这样我就可以隐藏缩放 div 如果不是,它说这个功能就是为了它: $imageCropper.cropit('isZoomable');
但是如何使用它?我是 jQuery 的初学者。
到目前为止,这是我的代码:
$(function() {
$('.image-editor').cropit({ imageBackground: true, imageBackgroundBorderWidth: 15 });
if ($('.image-editor').cropit('isZoomable')) {
alert("you can zoom");
} // EDIT: I added it but it's not working
$('form').submit(function() {
// Move cropped image data to hidden input
var imageData = $('.image-editor').cropit('export', {
type: 'image/jpeg',
quality: .9
});
$('.hidden-image-data').val(imageData);
// Print HTTP request params
var formValue = $(this).serialize();
$.ajax({
type: 'post',
url: 'doupload.php',
data: {bilddata: formValue},
success: function(data) {
}
});
return false;
});
})
就是这样:
if ($('.image-editor').cropit('isZoomable')) {
// code
}