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

后端 未结 6 1589
一个人的身影
一个人的身影 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:12

    Try the edge library on the repo here: https://github.com/tapmodo/Jcrop

    This should solve your problem. The lines that are changed to solve your problem:

    // Fix size of crop image.
    // Necessary when crop image is within a hidden element when page is loaded.
    if ($origimg[0].width != 0 && $origimg[0].height != 0) {
      // Obtain dimensions from contained img element.
      $origimg.width($origimg[0].width);
      $origimg.height($origimg[0].height);
    } else {
      // Obtain dimensions from temporary image in case the original is not loaded yet (e.g. IE 7.0).
      var tempImage = new Image();
      tempImage.src = $origimg[0].src;
      $origimg.width(tempImage.width);
      $origimg.height(tempImage.height);
    }
    

提交回复
热议问题