PHP Code:
// we need this
require_once(DIR . '/includes/functions_user.php');
// now we fetch it (url will be stored in $vbulletin->userinfo['avatarurl'])
fetch_avatar_from_userinfo($vbulletin->userinfo, false, true);
// make avatar size
$vbulletin->userinfo['avatarsize'] = ($vbulletin->userinfo['avatarwidth'] ? ' width="' . $vbulletin->userinfo['avatarwidth'] . '"' : '') . ($vbulletin->userinfo['avatarheight'] ? ' height="' . $vbulletin->userinfo['avatarheight']. '"' : '');