MyBB Community Forums
Show "default avatar" on Member List for users that do not have a avatar. - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Resources (https://community.mybb.com/forum-8.html)
+--- Forum: Tutorials (https://community.mybb.com/forum-38.html)
+--- Thread: Show "default avatar" on Member List for users that do not have a avatar. (/thread-103223.html)



Show "default avatar" on Member List for users that do not have a avatar. - Echos - 2011-09-05

What we will achieve (Madona does not have an avatar):
[Image: heym.jpg]

Open PHP file memberlist.php (its a good idea to make a note somewhere that you have edited this file), and find:

eval("\$user['avatar'] = \"".$templates->get("memberlist_user_avatar")."\";");
		}
		else
		{
			$user['avatar'] = "";
		}	

Replace with:
eval("\$user['avatar'] = \"".$templates->get("memberlist_user_avatar")."\";");
		}
		else
		{
			$user['avatar'] = "<img src='images/default_avatar.gif' alt='User Avatar' title='' />";
		}		

^as one could see, all we did was add an image source to the blank field. "default_avatar.gif" is already included in your MyBB images folder.

Upload that memberlist.php to your root folder.

If you go to your memberlist webpage it should show the default avatar for users that have not set an avatar.

Finally:
Go to: ACP > Configurations > Settings > Member List
And change your "Maximum Display Avatar Dimensions" setting to "44x44". This setting was chosen because "default_avatar.gif" is 44x44 pixels in size.

Some inspiration from my forum:
[Image: mynez.th.jpg]


RE: Show "default avatar" on Member List for users that do not have a avatar. - Akhlis - 2011-09-07

Thank you! Great tut!


RE: Show "default avatar" on Member List for users that do not have a avatar. - Omar G. - 2011-09-07

Looks good an useful, thanks for sharing ^^