Welcome to PhpBB3 BBCodes. Click here to register
Feed

Default Avatar

Default Avatar

Postby Stoker » 06 Apr 2010, 12:23

Default Avatar
Written by blkjack-21 and Stoker

This snippet will give users a default avatar. Off course only if they haven't chosen one in UCP :)
First version by blkjack-21 will display the default avatar everywhere on the board, the second version by Stoker will only display default avatar on viewtopic.



Version 1 by blkjack-21

Open: includes/functions_display.php
Find:
Code: Select all
if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
   {
      return '';

In line 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) . '" />';

no_avatar.gif
Last step is to upload this image to the images/avatars/gallery/ folder
no_avatar.gif (12.87 KiB) Viewed 508 times




Version 2 by Stoker

Open prosilver/template/viewtopic_body.html
Find:
Code: Select all
<!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{postrow.POSTER_AVATAR}</a><!-- ELSE -->{postrow.POSTER_AVATAR}<!-- ENDIF -->

In line add after:
Code: Select all
<!-- ELSE --><img src="{ROOT_PATH}images/gallery/no_avatar.gif" width="125" height="125" alt="" />



Open subsilver2/template/viewtopic_body.html
Find:
Code: Select all
         <!-- IF postrow.POSTER_AVATAR -->
            <tr>
               <td>{postrow.POSTER_AVATAR}</td>
            </tr>

Add after:
Code: Select all
         <!-- ELSE -->
            <tr>
               <td><img src="{ROOT_PATH}images/gallery/no_avatar.gif" width="125" height="125" alt="" /></td>
            </tr>


no_avatar.gif
Last step is to upload this image to the images/avatars/gallery/ folder
no_avatar.gif (12.87 KiB) Viewed 508 times
Image
User avatar
Stoker

Site Admin
 
 
Status: Offline
Age: 37
Posts: 820
Topics: 77
Joined: 03 Mar 2010, 18:56
Location: Denmark
PhpBB Version: 3.0.7-PL1
candefault, avatar, phpbb3


Re: Default Avatar

Postby Fire-Fox » 06 Apr 2010, 13:46

Nice one !
Image
User avatar
Fire-Fox

BBCoder IV
 
 
Status: Offline
Age: 27
Posts: 273
Topics: 39
Joined: 22 Mar 2010, 11:24
Location: Denmark
PhpBB Version: 3.0.7-PL1

Re: Default Avatar

Postby kevinviet » 08 Apr 2010, 05:29

Thanks Stoker
User avatar
kevinviet

Donator
 
 
Status: Offline
Posts: 42
Topics: 2
Joined: 06 Mar 2010, 02:52
PhpBB Version: 3.0.7-PL1

Re: Default Avatar

Postby Mario14125 » 11 May 2010, 16:58

1. We have chosen an avatar upload to any directory on your server. I suggest that you upload it to the folder in which there are other avatars: /images/avatars/gallery/
2. For this avatar should be access via the link http://www.twojeforum.pl/images/avatars ... avatar.png (of course replace the underlined name of the proper name for our server, and file an avatar
3. Open the file includes/functions_user.php and change the default values:
Code: Select all
'user_avatar'                   =>'',
'user_avatar_type'              => 0,
'user_avatar_width'             => 0,
'user_avatar_height'    => 0,

on
Code: Select all
'user_avatar'                   => 'http://www.twojeforum.pl/images/avatars/gallery/avatar.png',
'user_avatar_type'             => 2,
'user_avatar_width'             => 128,
'user_avatar_height'    => 128,

By changing the correct path to the avatar. Remember to include the default size of an avatar. In this case it is 128×128th If your avatar is a different size, enter the correct aspect ratio.

Changing the default avatar on existing users
If you want to set the default avatar of all those who do not have an avatar in general need to perform such a SQL query
Code: Select all
UPDATE `phpbb_users` SET `user_avatar` = 'http://www.twojeforum.pl/images/avatars/gallery/avatar.png',
`user_avatar_type` = '2',
`user_avatar_width` = '128',
`user_avatar_height` = '128'
WHERE `user_avatar` = '' ;

By changing the correct path to the avatar. Remember to include the default size of an avatar. In this case it is 128×128th If your avatar is a different size, enter the correct aspect ratio.

This method works "one time" - if the user removes the avatar from the profile it will not show him anything. So it is not forced upon anyone that does not want to have as an avatar is a must use "the default avatar.

///sorry for my bad english
» [ phpBB MODs Forum ] :: Click Here!
User avatar
Mario14125

BBCoder II
 
 
Status: Offline
Age: 17
Posts: 26
Topics: 2
Joined: 29 Apr 2010, 08:38
Location: Poland
PhpBB Version: 3.0.7-PL1

Re: Default Avatar

Postby cisco007 » 11 May 2010, 17:03

that is a lot of steps, where as the first post is easier, simpler, and no sql statements!
Chatbox is NOT!! for support, nor PM's
Don't know how to do something check this FORUM out!
Image
Image
User avatar
cisco007

Supporter
 
 
Status: Offline
Posts: 887
Topics: 10
Joined: 16 Mar 2010, 16:14
Location: Don't really know!
PhpBB Version: 3.0.7-PL1

Re: Default Avatar

Postby Mario14125 » 11 May 2010, 17:53

But I just wrote a another way of how you can make a default avatar... You do not need to scream...
» [ phpBB MODs Forum ] :: Click Here!
User avatar
Mario14125

BBCoder II
 
 
Status: Offline
Age: 17
Posts: 26
Topics: 2
Joined: 29 Apr 2010, 08:38
Location: Poland
PhpBB Version: 3.0.7-PL1

Re: Default Avatar

Postby Georgio » 26 May 2010, 17:10

Stoker » 06 Apr 2010, 14:23 wrote:Default Avatar
Written by blkjack-21 and Stoker

This snippet will give users a default avatar. Off course only if they haven't chosen one in UCP :)
First version by blkjack-21 will display the default avatar everywhere on the board, the second version by Stoker will only display default avatar on viewtopic. [...]


, what's the difference between v1 & v2, i want to chose your version; ¿what you recommend me?


what do you mean with "every where on the board" ? Do you mean down at "who's on line" at index??
Last edited by Georgio on 26 May 2010, 18:17, edited 1 time in total.
User avatar
Georgio

BBCoder II
 
 
Status: Offline
Age: 24
Posts: 48
Topics: 5
Joined: 06 Mar 2010, 17:10
Location: Cabanes, Spain
PhpBB Version: 3.0.7-PL1

Re: Default Avatar

Postby cisco007 » 26 May 2010, 17:31

it's up to you which one you want, it depends on which one you feel comfortable with, read the description it tells you the difference between the two!
Chatbox is NOT!! for support, nor PM's
Don't know how to do something check this FORUM out!
Image
Image
User avatar
cisco007

Supporter
 
 
Status: Offline
Posts: 887
Topics: 10
Joined: 16 Mar 2010, 16:14
Location: Don't really know!
PhpBB Version: 3.0.7-PL1

Re: Default Avatar

Postby billoo » 22 Jun 2010, 21:48

first one worked better for me
second one didnt work
when i used both the name of user was misplaced then i removed second one thanks
User avatar
billoo

BBCoder II
 
Windows XP Opera
Status: Offline
Posts: 24
Topics: 2
Joined: 15 May 2010, 20:46
PhpBB Version: 3.0.RC1

Re: Default Avatar

Postby Ashley.S. » 23 Jun 2010, 12:51

don't know if you lot are aware or not, but the second ways find does not work in the latest version of phpBB3, instead you need to instead find:

Code: Select all
   if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
   {
      return '';
   }


as posted here: http://www.phpbb.com/community/viewtopi ... #p11276755
Regards,
-Ashley.S. [ Pluto Hosting Chief Executive Officer & ProphpBB Moderator ]
Image
User avatar
Ashley.S.

BBCoder II
 
Windows 7 Firefox
Status: Offline
Age: 20
Posts: 18
Joined: 05 Mar 2010, 10:24
Location: Falmouth, Cornwall, UK
PhpBB Version: 3.0.7-PL1

Next

Return to Snippets



  • Similar topics
    Replies
    Views
    Last Post

Who is online

Users browsing this forum: No registered users and 1 guest