Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Badges

Try Vanilla Forums Cloud product

w1ckedsick

About

Username
w1ckedsick
Joined
Visits
19
Last Active
Roles
Member
Points
54
Badges
10
  • Re: I need to reference external Avatar source, please help?

    I found a way around that which worked... here's the slightly modified code that is working perfectly now:

    /**
     * Takes a user object, and writes out an anchor of the user's icon to the user's profile.
     *
     * @param object|array $User A user object or array.
     * @param array $Options
     * @return string HTML.
     */
    function userPhoto($User, $Options = array()) {
        if (is_string($Options)) {
            $Options = array('LinkClass' => $Options);
        }
        if ($Px = val('Px', $Options)) {
            $User = userBuilder($User, $Px);
        } else {
            $User = (object)$User;
        }
        $LinkClass = concatSep(' ', val('LinkClass', $Options, ''), 'PhotoWrap');
        $ImgClass = val('ImageClass', $Options, 'ProfilePhoto');
        $Size = val('Size', $Options);
        if ($Size) {
            $LinkClass .= " PhotoWrap{$Size}";
            $ImgClass .= " {$ImgClass}{$Size}";
        } else {
            $ImgClass .= " {$ImgClass}Medium"; // backwards compat
        }
        $FullUser = Gdn::userModel()->getID(val('UserID', $User), DATASET_TYPE_ARRAY);
        $UserCssClass = val('_CssClass', $FullUser);
        if ($UserCssClass) {
            $LinkClass .= ' '.$UserCssClass;
        }
        $LinkClass = $LinkClass == '' ? '' : ' class="'.$LinkClass.'"';
        $username = ($User->Name);
        $Photo = "{$username}.jpg";
        $Name = val('Name', $FullUser);
        $Title = htmlspecialchars(val('Title', $Options, $Name));
        if ($FullUser && $FullUser['Banned']) {
            $Photo = c('Garden.BannedPhoto', 'https://images.v-cdn.net/banned_large.png');
            $Title .= ' ('.t('Banned').')';
        }
        if ($Photo) {
            if (!isUrl($Photo)) {
                $PhotoUrl =  'https://www.website.com/avatar/'.$Photo;
            } else {
                $PhotoUrl = $Photo;
            }
        } else {
            $PhotoUrl = UserModel::getDefaultAvatarUrl($FullUser, 'thumbnail');
        }
        $href = (val('NoLink', $Options)) ? '' : ' href="'.url(userUrl($FullUser)).'"';
        return '<a title="'.$Title.'"'.$href.$LinkClass.'>'
                .img($PhotoUrl, ['alt' => $Name, 'class' => $ImgClass])
            .'</a>';
    }
    

    Thanks everyone :)

    R_Jvrijvlinder