<?php
function format_avatar($user)
{
static $users = array();
if(!isset($users[$user['uid']]))
{
$avatar_width_height = '';
$dimensions = explode('|', ($user['avatar']) ? $user['avatardimensions'] : '44|44');
if(is_array($dimensions) && $dimensions[0] && $dimensions[1])
{
$avatar_width_height = " width='{$dimensions[0]}' height='{$dimensions[1]}'";
list($max_width, $max_height) = explode('x', '50x50');
if($dimensions[0] > $max_width || $dimensions[1] > $max_height)
{
require_once MYBB_ROOT.'inc/functions_image.php';
$scaled_dimensions = scale_image($dimensions[0], $dimensions[1], $max_width, $max_height);
$avatar_width_height = " width='{$scaled_dimensions['width']}' height='{$scaled_dimensions['height']}'";
}
}
$users[$user['uid']] = array(
'avatar' => (!empty($user['avatar']) ? htmlspecialchars_uni($user['avatar']) : $GLOBALS['settings']['bburl'].'/images/default_avatar.gif'),
'dimensions' => $avatar_width_height
);
}
return $users[$user['uid']];
}