]> source.dussan.org Git - nextcloud-server.git/commitdiff
set initial cropper to max size
authorRobin Appelman <robin@icewind.nl>
Fri, 21 Oct 2016 13:08:36 +0000 (15:08 +0200)
committerRobin Appelman <robin@icewind.nl>
Fri, 21 Oct 2016 13:08:36 +0000 (15:08 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
settings/js/personal.js

index c5d659e5c8cf50b3201256a27ccca85c7a267a92..34fffe7dddebdc92f3f3dd1215f73d2624783c7c 100644 (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();
                });