Browse Source

#390: account difference in viewports

Rafał Pitoń 11 years ago
parent
commit
94e8a4d93a
2 changed files with 6 additions and 3 deletions
  1. 5 3
      misago/templates/misago/usercp/crop_avatar.html
  2. 1 0
      misago/users/views/usercp.py

+ 5 - 3
misago/templates/misago/usercp/crop_avatar.html

@@ -67,9 +67,11 @@
       var height = $image.height();
 
       {% if crop %}
-      selection_len = {{ crop.selection_len }};
-      start_x = {{ crop.start_x }};
-      start_y = {{ crop.start_y }};
+      original_width = {{ crop.image_width }};
+      change_ratio = width / original_width;
+      selection_len = change_ratio * {{ crop.selection_len }};
+      start_x = change_ratio * {{ crop.start_x }};
+      start_y = change_ratio * {{ crop.start_y }};
       {% else %}
       if (width < height) {
         selection_len = width;

+ 1 - 0
misago/users/views/usercp.py

@@ -177,6 +177,7 @@ def crop_avatar(request, use_tmp_avatar):
     if not use_tmp_avatar and request.user.avatar_crop:
         user_crop = request.user.avatar_crop.split(',')
         current_crop = {
+            'image_width': user_crop[0],
             'selection_len': user_crop[3],
             'start_x': user_crop[4],
             'start_y': user_crop[6],