Page 1 of 1

How to setup default avatar?

Posted: Mon Oct 31, 2011 3:56 am
by Matrix Leader
Hi guys,

On some forums that I visit, if I don't upload my own Avatar, I get the default forums avatar which usually has their logo....

how can I set a default avatar to be automatically assigned for members that sign up until they upload their own avatar (if they ever choose to)?

Re: How to setup default avatar?

Posted: Mon Oct 31, 2011 4:21 am
by John P
Make it default in the user table, field user_avatar.

Value should be "avatar/default.jpg"

Then all new users have this avatar until they choose another.

Re: How to setup default avatar?

Posted: Mon Oct 31, 2011 6:19 am
by Oyabun1
Stef775 wrote:Make it default in the user table, field user_avatar.

Value should be "avatar/default.jpg"

Then all new users have this avatar until they choose another.
I just tried that and it doesn't work.

However, there is a file edit that can be made that does work.

Download, backup, and open includes/functions_display.php

Find

Code: Select all

 	if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
	{
		return '';
	} 
Inline find

Code: Select all

 		return ''; 
Replace with

Code: Select all

 		return '<img src="images/avatars/gallery/no_avatar.gif" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />'; 
Change no_avatar.gif to the name of your default avatar and place the image in the avatars/gallery/ folder

Only use a good FTP client, such as FileZilla, to transfer the files. (FTP clients provided in host control panels can cause problems.) Use a proper text editor to make the edit, such as one of these, text editors. The encoding to save files in is UTF8 without BOM.

Re: How to setup default avatar?

Posted: Mon Oct 31, 2011 3:30 pm
by Matrix Leader
Oyabun1 wrote:
Stef775 wrote:Make it default in the user table, field user_avatar.

Value should be "avatar/default.jpg"

Then all new users have this avatar until they choose another.
I just tried that and it doesn't work.

However, there is a file edit that can be made that does work.

Download, backup, and open includes/functions_display.php

Find

Code: Select all

 	if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
	{
		return '';
	} 
Inline find

Code: Select all

 		return ''; 
Replace with

Code: Select all

 		return '<img src="images/avatars/gallery/no_avatar.gif" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />'; 
Change no_avatar.gif to the name of your default avatar and place the image in the avatars/gallery/ folder

Only use a good FTP client, such as FileZilla, to transfer the files. (FTP clients provided in host control panels can cause problems.) Use a proper text editor to make the edit, such as one of these, text editors. The encoding to save files in is UTF8 without BOM.
Thank you sir!

Re: How to setup default avatar?

Posted: Fri Dec 26, 2014 9:49 am
by SGMonkey
I know this is an old post. But as far as I am aware, it is still relevant.

I have a related question. If i wanted to link directly to the current themes "no_avatar.gif" how would I go about doing that?

f.ex, I have a forum with multiple styles, each style comes with a different "no_avatar.gif"

I tried doing something like this

Code: Select all

return '<img src="{T_THEME_PATH}/images/no_avatar.gif" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
But it doesn't seem to work. Just leaves me with the text, "user avatar" above the users profile field.

Any ideas how i would go about doing this?

Thanks in advance!

EDIT: On second look, this doesn't seem to do anything. No matter the image path, it just says "User avatar" above the profile. Even when I set it back to default it says the same thing.