Avatar resize not working properly.

Started by TetsuoS, December 11, 2006, 04:24:27 AM

Previous topic - Next topic

TetsuoS

As the title says:

Option 1: let the html do the resize: does not take into account the aspect ratio of the avatar, screwing it up. Ex. limit = 100x100 - avatar = 200x100 - resized avatar = 100x100

Option 2: let javascript do it: does not stay within the allowed maximum hight if the avatar has a bigger hight than width. Ex. limit = 100x100 - avatar = 200x400 - resized avatar = 100x200

Option 3: is not an option, since 1: it doesn't treat it as an external avatar, but as an uploadable one. 2: if the avatars are allready active they end up completely not resized.

It would be great if this functionality could be upgraded so it would resize the avatars correctly. or if someone would show a way to make it work the way it should/one would expect...


Any help is appreciated.
kind greets. :)

jerm


Tanks

#2
on my site it resizes normally.. i dont have the problem you describe so you must have messed up some code

Resizing only works for uploded or remote stored avatars

if you have some big avatars in your avatar folder that you uploaded via ftp and a user selects one of those avatars it wont resize it.

Thats my experience... but i dont know if this is the problem for you

TetsuoS

Using smf 1.1.1

Everybody should have the javascript resize error for remote avatars (if they use that as default method of resizing), since I checked the code and it contains the problem right there in the code, it simply doesn't do a height check if the width is found to be over the limit. I didn't mess up any code, the original code is insufficient.

I rewrote the code myself so the javascript works fine now.

I couldn't find the location where the html resize is done on avatars, so I couldn't check that, but assuming that it simply fills in the mentioned limits in a html img size tag, then it's logical for my descibed behaviour to occur. I did find the resize for ordinary images and that code seems to be clean and functioning properly (been a while since I looked over it), the simple html resize is not. This issue is present on all the versions of SMF I used so far (both modded and clean installs). I repeat, it's only non-functional for html resized external avatars. Javascript avatars issue is simply fixed by:

in any profile.template.php that can ever be in use:

Code (find) Select
{
document.getElementById("avatar").style.height = parseInt((maxWidth * tempImage.height) / tempImage.width) + "px";
document.getElementById("avatar").style.width = maxWidth + "px";
}


Code (replace) Select
{
var tempHeight = parseInt((maxWidth * tempImage.height) / tempImage.width);

if (maxHeight != 0 && tempHeight > maxHeight)
{
document.getElementById("avatar").style.width = parseInt((maxHeight * maxWidth) / tempHeight) + "px";
document.getElementById("avatar").style.height = maxHeight + "px";
}
else
{
document.getElementById("avatar").style.height = tempHeight + "px";
document.getElementById("avatar").style.width = maxWidth + "px";
}
}


And besides this also find any script.js that can ever be in use and do:

Code (find) Select
{
possibleAvatars[i].height = (smf_avatarMaxWidth * tempAvatar.height) / tempAvatar.width;
possibleAvatars[i].width = smf_avatarMaxWidth;
}


Code (replace) Select
{
var tempHeight = (smf_avatarMaxWidth * tempAvatar.height) / tempAvatar.width;

if (smf_avatarMaxHeight != 0 && tempHeight > smf_avatarMaxHeight)
{
possibleAvatars[i].width = (smf_avatarMaxHeight * smf_avatarMaxWidth) / tempHeight;
possibleAvatars[i].height = smf_avatarMaxHeight;
}
else
{
possibleAvatars[i].height = tempHeight;
possibleAvatars[i].width = smf_avatarMaxWidth;
}
}


Generally the files will only be found in the default theme, but you never know...


Quote from: Knat on December 30, 2006, 08:19:04 AM
on my site it resizes normally.. i dont have the problem you describe so you must have messed up some code

I'm quite certain that if you do as I described above in the opening post that you will have the mentioned behaviour, since it's even present on a clean smf install.

Quote from: Knat on December 30, 2006, 08:19:04 AM
Resizing only works for uploded or remote stored avatars

What you're talking about here is the GD module resize, there are options for resizing external avatars in smf (they just don't work very well and I'm not even talking about uploaded animated gif's yet, which are also not handled very well if they need to be resized, format changes into jpg or png, animation gone... but haven't checked that last thing since 1.1RC3)

Quote from: Knat on December 30, 2006, 08:19:04 AM
if you have some big avatars in your avatar folder that you uploaded via ftp and a user selects one of those avatars it wont resize it.

That is again the GD module resize at work, it will resize the image when it is being uploaded through smf, if it is allready active (present on the server) it won't resize, that is one of the issues I described above (the third).

KGIII

Resizing of any image via any means online, such as javascript or forcing the resized image with the GD lib or even via HTML resizing isn't a good method. HOWEVER - uploaded files should resize according to the GD library. Is your server using the newest version and is it working properly?

My PC Support Forum
Please ask in-thread before PMing
                   SMF Help
                   Visit My Blog

How can we improve the support process?:
http://www.simplemachines.org/community/index.php?topic=163533.0

SMF vs. Godzilla? Who do you think will win?

TetsuoS

Well, obviously it will cause extra work each time it has to be done for every person loading such a page using these online features, but sometimes there is no alternative...

For example, for people using remote avatars such a method has to be present or else they won't get resized at all. You can set it so that remote avatars are also uploaded to the server, but if the person alters it's avatar, the server won't automatically update it's cache (which is actually what it is, the upload remote avatars feature) and the person in question won't see his new avatar on a site using this method (which is logical of course, but still...). So online resizing is necessary for these things, there is no way around it (except for completely disallowing too large avatars, which is even more undesirable).

The server is using SMF 1.1.1 and the latest php. It was working perfectly up untill about a month ago, when we started having problems with lighttpd (the webserver), but these problems were totally unrelated. The 'fix' I installed for javascript resize is still doing its work very well... Be it with a small delay/performance penalty for correctly displaying all avatars that are in need of resizing.

Besides mentioned problems (and fix) everything concerning online avatars is working properly.

vbgamer45

Check your php settings. I think the problem lies with a php upgrade for allowing fopen to open a remote file. In the new PHP you need to set it in order to allow it to get access to that file.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: