LWillmann |
01-29-2006 09:02 PM |
Cludrunner, thanks for this! I really like it.
I had an issue with the stock no_avatar.gif file being smaller than the size you specified in the .xml file, and it doesn't stretch very well, so I wrote something to work with avatars that are a different size.
This code change will resize the avatar proportionally if either dimension larger than the set size (I left it set to 100x100), or if it's equal to the set size or smaller, it will use the set size.
To adjust your script to make this work do this:
1) Go to your Admin Control Panel
2) Go to the Plugin manager
3) Choose to edit the Navbar Redux plugin.
Find this code:
PHP Code:
$av_url = fetch_avatar_url($vbulletin->userinfo['userid']);
if (!$av_url){
$av_url = $stylevar['imgdir_misc'] . '/noavatar.gif';
} else {
$av_url = $vbulletin->options['bburl'] . '/' . $av_url[0];
}
$nav_av_image = '<img width="100" height="100" src="'.$av_url.'" border="0">';
And replace it with this:
PHP Code:
$av_url = fetch_avatar_url($vbulletin->userinfo['userid']);
if (!$av_url){
$av_url = $stylevar['imgdir_misc'] . '/noavatar.gif';
} else {
$av_url = $vbulletin->options['bburl'] . '/' . $av_url[0];
}
$av_size = GetImageSize($av_url);
$max_av_disp_height = '100';
$max_av_disp_width = '100';
if ($max_av_disp_width < $av_size[0])
{
$av_disp_width = $av_size[0]/$max_av_disp_width;
$av_disp_height = $av_size[1]/$av_disp_width;
}
else
{
$av_disp_width = $av_size[0];
$av_disp_height = $av_size[1];
}
if ($max_av_disp_height < $av_size[0])
{
$av_disp_height = $av_size[1]/$max_av_disp_height;
$av_disp_width = $av_size[0]/$av_disp_height;
}
else
{
$av_disp_width = $av_size[0];
$av_disp_height = $av_size[1];
}
$nav_av_image = '<img width="'.$av_disp_width.'" height="'.$av_disp_height.'" src="'.$av_url.'" border="0">';
This should make the avatar display better. Editing the NAVBAR template after this would allow you to specify that particular cell in the table to be horizontally and vertically centered so that the avatar was centered in the block opening if the Welcome panel is talled than the avatar.
Thanks again!
*Clicks Install
|