[HowTo] Fix empty default user avatar in custom theme user menu
#2
You can actually do this with javascript . Give your avatar a class of header_avatar img and add js code at the bottom of footer.

Example code
<li class="header_avatar"><img src="{$mybb->user['avatar']}" height="30px" width="30px" align="top" class="miniav"/></li>

<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.gif');
 }
});
</script>

You might say aha - but what if user has no js enabled. Um, if they have no js enabled on a 1.8 mybb board then no avatar in the header is a minor issue compared to the rest.
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved


Reply


Messages In This Thread
RE: [HowTo] Fix empty default user avatar in custom theme user menu - by Leefish - 2015-02-05, 05:11 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)