[HowTo] Fix empty default user avatar in custom theme user menu
#4
(2015-02-05, 04:43 PM)SvePu Wrote: Include the small function into your own theme plugin

(2015-02-05, 05:11 PM)Leefish Wrote: You can actually do this with javascript

You can actually do this with pure CSS:

<div class="avatar-box">
    <img src="{$mybb->user['avatar']}" alt="avatar" />
</div>
.avatar-box { height: 30px; width: 30px; background: url('../../../images/default_avatar.png') no-repeat; background-size: 100% auto; }
.avatar-box img { height: 30px; width: 30px; }
.avatar-box img[src=""] { display: none; }
If the user has set his own avatar, the default one gets covered behind - if not, the image is hidden to prevent the browser from rendering a broken image indicator.
devilshakerz.com/pgp (DF3A 34D9 A627 42E5 BC6A 6750 1F2F B8AA 28FF E1BC) ▪ keybase.io/devilshakerz
Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)