2015-04-24 11 views
5

mã của tôi html cho cropit:jQuery phương pháp xuất khẩu cropit trở lại chỉ 'dữ liệu :,' chuỗi

<div id="image-cropper" style="direction: ltr"> 
    <div class="row margin-top-25"> 
     <div class="col-md-8 col-md-offset-2"> 
      <div class="cropit-image-preview-container"> 
       <div class="cropit-image-preview"></div> 
      </div> 
     </div> 
    </div> 
    <div class="row margin-top-15"> 
     <div class="col-md-4 col-md-offset-4"> 
      <input type="range" class="cropit-image-zoom-input" /> 
     </div> 
    </div> 
    <div class="row margin-top-15"> 
     <div class="col-md-4 col-md-offset-4"> 
      <input type="file" style="display: none" class="cropit-image-input" /> 
      <div class="R_butt_blue choose_pic text-center">انتخاب تصویر</div> 
     </div> 
    </div> 

</div> 

và mã javascript của tôi cho cropit:

$('.choose_pic').click(function(){ 
    $('.cropit-image-input').click(); 
}); 

var z = $('#image-cropper').cropit({ 
    exportZoom: 1, 
    imageBackground: true, 
    imageBackgroundBorderWidth: 15 // Width of background border 
}); 
$('.send_image').click(function(){ 
    var h = z.cropit('export'); 
    $('#photo_show img').attr({ src: h }); 
}); 

Tôi muốn cắt một hình ảnh bằng cách sử dụng plugin jquery cropit, tôi đọc toàn bộ tài liệu và đa số example on web, nhưng điều đó chỉ trả về một chuỗi có chứa data:, tôi không biết điều gì là sai?

Trả lời

4

Bạn nên xác định lớp học .cropit-image-preview css để đặt chiều rộng và chiều cao của hình ảnh được cắt.

.cropit-image-preview { 
    /* You can specify preview size in CSS */ 
    width: 100px; 
    height: 100px; 
} 

và cũng sử dụng bộ chọn như thế này:

var z = $('#image-cropper'); 
z.cropit({ 
    exportZoom: 1, 
    imageBackground: true, 
    imageBackgroundBorderWidth: 15 // Width of background border 
}); 

Hãy thử điều này: http://jsfiddle.net/grzveb09/

+1

Vâng, đó là một công việc tốt, cảm ơn bạn bè của tôi :) –

Các vấn đề liên quan