Need hlep displaying member avatar in header.
#1
I want to display the members avatar in the header as shown in the photo1 below.

I have it working properly with the following code inserted into the top of  the [header_welcomeblock_member] template as long as the member has uploaded his own avatar instead of using the default avatar.

<a href="usercp.php?action=avatar" title="click"><img src="{$mybb->user['avatar']}" id="headeravatar"></a><span class="welcome">{$lang->welcome_back} &nbsp;&nbsp;<a href="{$mybb->settings['bburl']}/member.php?action=logout&amp;logoutkey={$mybb->user['logoutkey']}"><span id="logbutton">{$lang->welcome_logout}</span></a>
</div><span class="smalltext">Click to change avatar</span>

If the member is still using the default avatar it isn't displayed as you can see in photo2. What can I do to get the default avatar to display in the header when an the member hasn't uploaded a custom avatar?  - Thanks!

Photo1:
   

Photo2:
   
Reply
#2
you might want to try this out Wink
https://community.mybb.com/mods.php?action=view&pid=375
Reply
#3
You can do it without a plugin, just upload a default avatar in your themes images folder.

<a class="header_avatar" href="{$mybb->settings['bburl']}/usercp.php?action=avatar"> <img src="{$mybb->user['avatar']}" height="25px" width="25px" /></a>

<script>
$(document).ready(function() {
//create a default avatar for those without one.
if($('.header_avatar img', this).attr('src') == ''){
$('.header_avatar img').attr('src', "images/default_avatar.png");
}
});
</script>
[Image: sig2.jpg]
Reply
#4
Thanks you so much! That code worked perfectly. Just what I was looking for. Big Grin
Reply
#5
(2016-11-02, 05:01 PM)iAndrew Wrote: You can do it without a plugin, just upload a default avatar in your themes images folder.

<a class="header_avatar" href="{$mybb->settings['bburl']}/usercp.php?action=avatar"> <img src="{$mybb->user['avatar']}" height="25px" width="25px" /></a>

<script>
$(document).ready(function() {
//create a default avatar for those without one.
if($('.header_avatar img', this).attr('src') == ''){
$('.header_avatar img').attr('src', "images/default_avatar.png");
}
});
</script>

The code above worked great in the header template. I would like to do the same in the changeuserbox template next to the username when a member is making a reply or new post but if a member has a default avatar, the default avatar doesn't show up. How can I modify the code to make it work in the changeuserbox template?

BTW, I don't use the change user feature in that template. I only show the username
Thanks!

   
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)