Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profile module, unable to create avatar in IE, opera. with solution (Trac #1167) #1167

Closed
elgg-gitbot opened this issue Feb 16, 2013 · 5 comments

Comments

@elgg-gitbot
Copy link

Original ticket http://trac.elgg.org/ticket/1167 on 39599599-09-28 by trac user mangust, assigned to unknown.

Elgg version: 1.6

Hi, i am fixing profile plugin. Users of my test site can't create avatar on their profiles. I am nearly to fix it. But need help from original coder.

Issue was reported on IE and Opera, but no problem in Firefox.

  1. Noticed that IE complain:

Message: Invalid argument.
Line: 315
Char: 5
Code: 0
URI: http://live.riki.ru/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js

  1. I've updated imgareaselect script to latest version from http://odyniec.net/projects/imgareaselect/. Because i seen it work on IE. Problem gone, but

  2. Appear in mod/profile/editicon.php, function preview around line 70 ( $("#user_avatar_preview > img").css({....... ):

    function preview(img, selection) {
    //add this line to prevent IE/Opera bug
    if ( selection.width == 0 || selection.height ==0 ) return;

    var origWidth = $("#user_avatar").width(); //get the width of the users master photo
    var origHeight = $("#user_avatar").height(); //get the height of the users master photo
    var scaleX = 100 / selection.width;
    var scaleY = 100 / selection.height;
    
    $("#user_avatar_preview > img").css({
        'width' : Math.round(scaleX * origWidth) + 'px',
        'height' : Math.round(scaleY * origHeight) + 'px',
        'marginLeft' : '-' + Math.round(scaleX * selection.x1) + 'px',
        'marginTop' : '-' + Math.round(scaleY * selection.y1) + 'px'
     });
    

    }

  3. Problem is that then you just click on an image selection.width and selection.width become 0. After some math manipulation some zeroes and infinity values going to .css function. And IE reject to apply that values.

  4. Solution is to add check
    if ( selection.width == 0 || selection.height ==0 ) return;
    just in the beginning of a function to prevent IE/Opera confusion.

I'm new in trac system. Let me know if i do wrong report or any hints.

@elgg-gitbot
Copy link
Author

cash wrote on 39826176-03-31

I can confirm that you cannot select a region in Elgg 1.6 for the profile icon with IE8.

@elgg-gitbot
Copy link
Author

Milestone changed to Elgg 1.7 by cash on 39826176-03-31

@elgg-gitbot
Copy link
Author

trac user tomv wrote on 39850824-03-22

Also problem in IE7
Proposed solution does not work for me; instead also breaks function in FF

@elgg-gitbot
Copy link
Author

trac user tomv wrote on 39850887-05-07

Ok, solution that works is:

in .../mod/profile/views/default/profile/editicon.php

Line 68..

//function to display a preview of the users cropped section
function preview(img, selection) {

    var sw = selection.width;
    var sh = selection.height;
    if ( sw == 0 ) { sw =1; }
    if ( sh == 0 ) { sh =1; }


    var origWidth = $("#user_avatar").width(); //get the width of the users master photo
    var origHeight = $("#user_avatar").height(); //get the height of the users master photo
    var scaleX = 100 / sw; 
    var scaleY = 100 / sh; 
    $('#user_avatar_preview > img').css({ 
        width: Math.round(scaleX * origWidth) + 'px', 
        height: Math.round(scaleY * origHeight) + 'px', 
        marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', 
        marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' 
     }); 
}

@elgg-gitbot
Copy link
Author

cash wrote on 39931897-10-20

Fixed in plugins commit 1139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant