1
我在應用程序中使用jcrop,我想與選擇(x, y, w, h)
打開圖像,當我只給出x, width and height
它的工作原理,但是當我添加的'y'
值它,它沒有給我正確的價值觀Jcrop setSelect錯誤的價值觀
這是我的代碼:
function initJcrop() {
$('#target').Jcrop({
aspectRatio: 3, //If you want to keep aspectRatio
allowResize: true ,
boxWidth: 975, //Maximum width you want for your bigger images
boxHeight: 325, //Maximum Height for your bigger images
minSize: [900, 300],
<?php $image_crop = json_decode($article->image_crop);?>
setSelect: [<?php echo $image_crop->x;?>, <?php echo $image_crop->y;?>, <?php echo $image_crop->w;?>, <?php echo $image_crop->h;?>],
allowSelect: false ,
onSelect: storeCoords ,
addClass: 'jcrop-centered',
onChange: storeCoords
},function()
{
// alert('Now you see smaller preview of your bigger one.');
});
}
function storeCoords(c) {
jQuery('#x').val(Math.round(c.x));
jQuery('#y').val(Math.round(c.y));
jQuery('#w').val(Math.round(c.w));
jQuery('#h').val(Math.round(c.h));
};