如何在jQuery裁剪器中设置裁剪框

编程入门 行业动态 更新时间:2024-10-28 09:15:41
本文介绍了如何在jQuery裁剪器中设置裁剪框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用的是cropper,这是我在 cropper网站上找到的一个jQuery插件. > 我在1080h上具有全高清1920w的图像大小,并且需要让用户能够以675 * 1080的固定框大小进行裁剪,我的问题是如何设置此插件的选项? 我尝试执行以下操作未成功:

I'm using cropper, it's a jquery plugin I found at cropper web site. I have an image size full hd 1920w on 1080h, and I need to give the user ability to crop in fixed box size 675*1080, my question is how do I set the options of this plugin ? I've tried to do the follow with no success:

var c1 = $('.cropper-example-1 img').cropper({ //aspectRatio: 10 / 16, strict: true, background:false, guides: false, highlight: false, dragCrop: false, movable: false, resizable: false, mouseWheelZoom: false, touchDragZomm:false, built: function () { //alert(1); // $(this).cropper('setData', 0, 0, 675, 1080,90); // $(this).cropper('setCropBoxData', 0, 0, 1920, 1080); } });

推荐答案

经过许多次尝试后,这对我有用...我需要将初始宽度和高度设置为240px x 607px,这是我的代码.

After soo many trials this worked for me... i needed to set the initial width and height to 240px by 607px and this is my code.

var cropper; var imgx; $(function(){ var imgx = $('#cpdiv').find('img'); cropper = new Cropper(imgx[0], { //aspectRatio: 1/2, autoCropArea: 0, strict: false, guides: false, highlight: true, dragCrop: false, //cropBoxMovable: false, cropBoxResizable: false, data:{ width: 240, height: 607, }, crop(event) { console.log(event.detail.width); console.log(event.detail.height); }, }); });

我尝试使用setCropBoxData({})函数,该函数不起作用..但是这种方法对我有用.

i tried using the setCropBoxData({}) function which didnt work.. but this approach worked for me.

更多推荐

如何在jQuery裁剪器中设置裁剪框

本文发布于:2023-10-30 00:11:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:器中   如何在   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!