| Author |
Post |
|
|
#1 Wed Dec 13, 2006 8:16 am
|
|
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.
|
|
|
#2 Wed Dec 13, 2006 12:30 pm
|
|
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.'"';
|
|
|
#3 Wed Dec 13, 2006 8:17 pm
|
|
Member
Registered: Aug 2006
Posts: 5
Location: Kansas, ick.
|
Ah, thanks, fixed that but still a blank page. 
|
|
|
#4 Wed Dec 13, 2006 9:09 pm
|
|
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']);
|
|
|
#5 Wed Dec 13, 2006 9:16 pm
|
|
Member
Registered: May 2005
Posts: 298
Location: 98671
|
Error that came up...
E_NOTICE - Undefined variable: postsdata
|
|
|
#6 Thu Dec 14, 2006 8:03 am
|
|
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...
|
|
|
#7 Thu Dec 14, 2006 9:01 am
|
|
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 ==  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.
|
|
|
#8 Thu Dec 14, 2006 9:03 am
|
|
Developer
Registered: Apr 2004
Posts: 2224
Location: Belgium
|
floor() or ceil() 
|
|
|
#9 Thu Dec 14, 2006 9:06 am
|
|
Member
Registered: Aug 2006
Posts: 5
Location: Kansas, ick.
|
Well, that seems a bit obvious, why didn't I think of that.. thank you.
|