Displaying “logged_in_members” avatar
Posted: 30 June 2009 09:42 AM   [ Ignore ]
Member
RankRankRank
Total Posts:  139
Joined  2007-05-31

I’m sure there is something obvious that I’m missing here. I want to display my logged_in_members avatar (and a default image if they don’t have one).

I’ve been attempting to use the {exp:user:stats} tag to pull in the image but I’m not having any success.

<div class="avatar_wrapper">
    
{exp:user:stats username="{username}"}{if avatar_url != ""}<img src="{avatar_url}{avatar_filename}" width="{avatar_width}" height="{avatar_height}" alt="{username}'s avatar" />{if:else}<img src="default_avatar.gif" width="105" height="75" alt="{username} has not uploaded an avatar" />{/if}{/exp:user:stats}

</div

I’ve tried both the {username} and {member_id} - both values are present and available. However, when I feed the {username} varialbe the {exp:user:stats} tag doesn’t spit out any data what so ever. If I hard-code the username parameter within the tag I get:

<div class="avatar_wrapper">
    <
img src="http://www.shirtfight.com/images/avatars/" width="0" height="0" alt="admin's avatar" />
</
div

Now this is even more odd because this user has no avatar so the second half of the condition should be what displays.

I’m clearly going down the wrong path here. Anyone have a tip or two to bet me back on the right track?

Thanks in advance!

Profile
 
 
Posted: 30 June 2009 10:15 AM   [ Ignore ]   [ # 1 ]
Member
RankRankRank
Total Posts:  139
Joined  2007-05-31

So I guess I was keying off the wrong variable.

Should be something like

<div class="avatar_wrapper">
    
{exp:user:stats member_id="{member_id}"}{if avatar_filename}<img src="{avatar_url}{avatar_filename}" width="{avatar_width}" height="{avatar_height}" alt="{username}'s avatar" />{if:else}<img src="default_avatar.gif" width="105" height="75" alt="{username} has not uploaded an avatar" />{/if}{/exp:user:stats}

</div
Profile
 
 
Posted: 30 June 2009 10:25 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  8223
Joined  2006-10-18

Correct wink

You also shouldn’t even need to specify the member_id or username parameters wink

 Signature 
Profile