set initial cropper to max size

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2016-10-21 15:08:36 +02:00
parent ac167d4dc6
commit 55c445ff39
No known key found for this signature in database
GPG Key ID: 425003AC385454C5
1 changed files with 6 additions and 4 deletions

View File

@ -139,16 +139,18 @@ function showAvatarCropper () {
$cropperImage.attr('src',
OC.generateUrl('/avatar/tmp') + '?requesttoken=' + encodeURIComponent(oc_requesttoken) + '#' + Math.floor(Math.random() * 1000));
// Looks weird, but on('load', ...) doesn't work in IE8
$cropperImage.ready(function () {
$cropperImage.load(function () {
var img = $cropperImage.get()[0];
var selectSize = Math.min(img.width, img.height);
var offsetX = (img.width - selectSize) / 2;
var offsetY = (img.height - selectSize) / 2;
$cropperImage.Jcrop({
onChange: saveCoords,
onSelect: saveCoords,
aspectRatio: 1,
boxHeight: 500,
boxWidth: 500,
setSelect: [0, 0, 300, 300]
setSelect: [offsetX, offsetY, selectSize, selectSize]
}, function() {
$cropper.show();
});