UseBB Community

The official board for UseBB help and discussion

UseBB Community » Resources & Customization » Avatar Maximum Size

Avatar Maximum Size

Moderators: Gaia.

Page: 1

Author Post
Member
Registered: Aug 2006
Posts: 5
Location: Kansas, ick.
Hello, was trying to add a way to resize an avatar if it was over a set limit. I think I got most of it all working, I have all the config variables in, ACP works, its in the config file and all. But if I view topic.php I get a blank page. The below code is placed just after the force height/width statements.

$avatar_resized = 0;
$avatar_new_width = 0;
$avatar_new_height = 0;
$avatar_info = getimagesize($postsdata['avatar_remote']);
$avatar_current_width = $avatar_info[0];
$avatar_current_height = $avatar_info[1];

if ($avatar_current_height > $functions->get_config('avatars_max_height') && $functions->get_config('avatars_max_height') != 0)
{
$avatar_new_height = $functions->get_config('avatars_max_height');
$avatar_resize_percent = ($avatar_current_height / $avatar_new_height);
$avatar_new_width = ($avatar_current_width / $avatar_resize_percent);
$avatar_resized = 1;
}
if ($avatar_resized = 1)
{
$avatar_force_height = ' height="'.$avatar_new_height.'"';
$avatar_force_width = ' width="'.$avatar_new_width'"';
$avatar_resized = 0;
}
if ($avatar_current_width > $functions->get_config('avatars_max_width') && $functions->get_config('avatars_max_width') != 0)
{
$avatar_new_width = $functions->get_config('avatars_max_width');
$avatar_resize_percent = ($avatar_current_width / $avatar_new_width);
$avatar_new_height = ($avatar_current_height / $avatar_resize_percent);
$avatar_resized = 1;
}
if ($avatar_resized = 1)
{
$avatar_force_height = ' height="'.$avatar_new_height.'"';
$avatar_force_width = ' width="'.$avatar_new_width.'"';
}

I think this should work. But somethings breaking it. If I comment out the above, it works like normal. I havn't used php in quite along time, so I'm a bit confused as to why this isn't working. Any help would be appreciated.
Member
Registered: May 2005
Posts: 298
Location: 98671
Right off, I see that this...
$avatar_force_width = ' width="'.$avatar_new_width'"';

Should be...
$avatar_force_width = ' width="'.$avatar_new_width.'"';
Member
Registered: Aug 2006
Posts: 5
Location: Kansas, ick.
Ah, thanks, fixed that but still a blank page. :(
Member
Registered: May 2005
Posts: 298
Location: 98671
I don't remember error message, but below came back as error.

$avatar_info = getimagesize($postsdata['avatar_remote']);
Member
Registered: May 2005
Posts: 298
Location: 98671
Error that came up...

E_NOTICE - Undefined variable: postsdata
Member
Registered: Aug 2006
Posts: 5
Location: Kansas, ick.
Well, I don't know what I did. But it -kind- of works now. At least, the image shows up with a height/width of 0 :| so. Thats better than a blank page! Thanks for the insight.

I think it might have been caching the broken page, which is why it just suddenly started working. Sometimes I wonder if ctrl+f5 really does anything...
Member
Registered: Aug 2006
Posts: 5
Location: Kansas, ick.
Finally! Works great now. I feel kind of stupid really, the problem was:

if ($avatar_resized = 1)

should have been == :D
Now, if I can figure out if you can make php round up to whole numbers. Having an image height of 204.54545454545 is kind of irritating. But at least it all works.
Developer
Registered: Apr 2004
Posts: 2224
Location: Belgium
floor() or ceil() ;)
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Aug 2006
Posts: 5
Location: Kansas, ick.
Well, that seems a bit obvious, why didn't I think of that.. thank you.

Page: 1

UseBB Community » Resources & Customization » Avatar Maximum Size

UseBB Community is powered by UseBB 1 Forum Software