[Snippet] Avatar everywhere

Little Mods and Snips 2

[Snippet] Avatar everywhere

Postby Sekuro » 18 Dec 2011, 22:00

Avatar everywhere

With this Snippet you can show your Avatar everywhere on Board

open

includes/functions.php

find

Code: Select all
    // The following assigns all _common_ variables that may be used at any point in a template.
    $template->assign_vars(array(


after add

Code: Select all
    'USER_AVATAR'                    => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']),


find

Code: Select all
 ?>


before add

Code: Select all
/**
* Get user avatar
*
* @param string $avatar Users assigned avatar name
* @param int $avatar_type Type of avatar
* @param string $avatar_width Width of users avatar
* @param string $avatar_height Height of users avatar
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
* @return string Avatar image
*/
if (!function_exists('get_user_avatar')){
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
{
    global $user, $config, $phpbb_root_path, $phpEx;

    if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
    {
        return '';
    }

    $avatar_img = '';

    switch ($avatar_type)
    {
        case AVATAR_UPLOAD:
            if (!$config['allow_avatar_upload'] && !$ignore_config)
            {
                return '';
            }
            $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
        break;

        case AVATAR_GALLERY:
            if (!$config['allow_avatar_local'] && !$ignore_config)
            {
                return '';
            }
            $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
        break;

        case AVATAR_REMOTE:
            if (!$config['allow_avatar_remote'] && !$ignore_config)
            {
                return '';
            }
        break;
    }

    $avatar_img .= $avatar;
    return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}}


open

includes/functions_display.php

find

Code: Select all
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
{
    global $user, $config, $phpbb_root_path, $phpEx;

    if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
    {
        return '';
    }

    $avatar_img = '';

    switch ($avatar_type)
    {
        case AVATAR_UPLOAD:
            if (!$config['allow_avatar_upload'] && !$ignore_config)
            {
                return '';
            }
            $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
        break;

        case AVATAR_GALLERY:
            if (!$config['allow_avatar_local'] && !$ignore_config)
            {
                return '';
            }
            $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
        break;

        case AVATAR_REMOTE:
            if (!$config['allow_avatar_remote'] && !$ignore_config)
            {
                return '';
            }
        break;
    }

    $avatar_img .= $avatar;
    return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}


replace with

Code: Select all
if (!function_exists('get_user_avatar')){
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
{
    global $user, $config, $phpbb_root_path, $phpEx;

    if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
    {
        return '';
    }

    $avatar_img = '';

    switch ($avatar_type)
    {
        case AVATAR_UPLOAD:
            if (!$config['allow_avatar_upload'] && !$ignore_config)
            {
                return '';
            }
            $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
        break;

        case AVATAR_GALLERY:
            if (!$config['allow_avatar_local'] && !$ignore_config)
            {
                return '';
            }
            $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
        break;

        case AVATAR_REMOTE:
            if (!$config['allow_avatar_remote'] && !$ignore_config)
            {
                return '';
            }
        break;
    }

    $avatar_img .= $avatar;
    return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}}


open

includes/ucp/ucp_pm_viewmessage.php

find

Code: Select all
    if (!function_exists('get_user_avatar'))
    {
        include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    }


replace with

Code: Select all
    //if (!function_exists('get_user_avatar'))
    //{
        include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    //}    


Clear all Board-, Style- and Browsercaches

Now u can put the Avatar everywhere in Forum-Templates via {USER_AVATAR}
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900


Return to Snip Cl@ss II

Who is online

Users browsing this forum: No registered users and 1 guest

cron