Notice: Include
assets/js/plugins/crop.js
before using the crop plugin.
HTML Setup:
<!-- The crop container -->
<div id="crop-container" style="display: none;">
<div class="crop-preview"></div>
<button type="button" class="cancel">Cancel</button>
<button type="button" class="save">Save</button>
</div>
JavaScript:
// Filepicker plugin
var FP = $('#filepicker').filePicker({...});
// Crop plugin call
FilepickerCrop(FP, {
container: $('#crop-container'),
// more options ...
});
Requires Bootstrap.
HTML Setup:
<div class="modal fade" id="crop-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Crop image</h4>
</div>
<div class="modal-body">
<div class="crop-preview"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary save" data-loading-text="Saving...">Save</button>
</div>
</div>
</div>
</div>
JavaScript:
// Filepicker plugin
var FP = $('#filepicker').filePicker({...});
// Crop plugin call
FilepickerCrop(FP, {
container: $('#crop-modal'),
modal: true, // Optional, because it auto detects Bootstrap modal support.
// more options ...
});
Aspect ratio of width/height.
n/a
1
(for square)Minimum width/height, use 0 for unbounded dimension.
n/a
[150, 250]
Maximum width/height, use 0 for unbounded dimension.
n/a
[150, 250]
Set an initial selection area.
n/a
The jQuery object for the crop container or Bootstrap modal.
n/a
$('#crop-container')
/ $('#crop-modal')
Whether to enable Bootstrap modal. Optional, because it auto detects Bootstrap modal support.
false
/ true
when using Bootstrap modalThe jQuery object for the element where the image preview will be rendered.
container.find('.crop-preview')
$('.crop-preview')
The Query object for the button that will open the crop. When using the uploader with filesList it will look into the download template for a .crop
button.
If Filepicker is used without a the filesList, this jQuery object must have the data-file
attribute set with the file object. Edit basic.html
to see how you can attach a file object to the button.
filesList.find('.crop')
$('.crop-btn')
The jQuery object for the button that will save the cropped image.
container.find('.save')
$('.save-crop-btn')
The jQuery object for the button that will cancel the crop.
container.find('.cancel')
$('.cancel-crop-btn')