jCrop (jQuery) sometimes fails to load image/cropper area

后端 未结 6 1744
一个人的身影
一个人的身影 2021-02-07 08:46

I\'ve got a pretty simple problem, but I\'ve become clueless on what is causing the problem. In one of my applications I\'m using jCrop as a small add-on to crop images to fit i

6条回答
  •  天命终不由人
    2021-02-07 09:06

    Here my weird but fantastic solution:

    if (obj.tagName == 'IMG') {
      var tempImage = new Image();
        tempImage.src = $origimg[0].src;
        $origimg.width(tempImage.width);
        $origimg.height(tempImage.height);
      if ($origimg[0].width > 1 && $origimg[0].height > 1) {
        $origimg.width($origimg[0].width);
        $origimg.height($origimg[0].height);
      } else {
        var tempImage = new Image();
        tempImage.src = $origimg[0].src;
        $origimg.width(tempImage.width);
        $origimg.height(tempImage.height);
         //console.log('error'+$origimg[0].width + $origimg[0].height);
      } 
    

提交回复
热议问题