MyBB Community Forums

Full Version: Avatar on Index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Removed]
<img src="{$mybb->user['avatar']}" alt="Avatar" width="90px"; height="90px"; style="margin-top: 0px;">
[Removed]
Don't know. I leave it as a broken image, they either deal with it or use an avatar.
Use this if you want to display a default avatar if users don't upload one - http://mods.mybb.com/view/default-avatar
(2010-12-20, 01:55 AM)flav1us Wrote: [ -> ]What if the user doesn't have an avatar and I want to display a default one?

I think you need to do a query or a plugin to do that, But if you did this with some edits it shoud work.

http://www.webdesignerwall.com/tutorials...th-jquery/
A little jQuery can get the problem solved. Give the user's avatar a class of "avatar" and have another class "avatar2" or something different to display the default avatar as a background image.

So
.avatar2 {
	background: url(images/theme/avatar2.png) top left no-repeat;
	height: 90px;
	width: 90px;	
}

Then, add the jQuery:
if (jQuery('.avatar').attr('src') == '') {
	jQuery('.avatar').addClass('avatar2');
}
Is this for a personal site? If so, look into a plugin that inserts a default avatar, or install the PHP Conditionals plugin. I don't see why you would want to load up jQuery for one thing.