Back to vBulletin 3.6 Template Modifications

Remote Avatars
Mod Version: 0.11, by Rawhide

This modification is in the archives.
vB Version: 3.6.3 Rating: (1 vote - 5.00 average) Installs: 3
Released: 16 Nov 2006 Last Update: Never Downloads: 2
Not Supported Template Edits Is in Beta Stage  

This is a template modification for vBulletin 3.6.3 to enable the use of remote or default avatars. It disables the inbuilt avatar handling system and does not allow avatar uploading.

A regular expression is used to prevent html or other code from being used and to prevent the avatar from stretching the page layout. You can set the width and height of the avatar from 20 pixels to 120, if not set the same as the original image, the image will be stretched.

As of this version, v0.1 BETA, only the postbit_legacy is supported. Although it will not be hard to modify it to suit the standard postbit.

Step 1: Create the following 5 User Profile Fields

Title: Avatar
(field6 in my examples)
Profile Field Type: Single-Selection Radio Buttons
Options: Required, Editable
Description: Avatars are small graphics that are displayed under your username whenever you post. This is a global setting that will turn off your avatar altogether or let you choose a default or custom one.
Items per line: 0
Options:
None
Default
Custom

Set Default: Yes
Display Order: (Whatever ends up being 1st)
Field Required: Yes, Always
Field Editable by User: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: No
Allow user to input their own value for this option: No
Max length of allowed user input: 100
Field Length: 25
Regular Expression:
Which page displays this option?: Options: Other

---

Title: Default Avatar
(field7 in my examples)
Profile Field Type: Single-Selection Menu
Options: Required, Editable
Description: A selection of default avatars.
Set Default: Yes, but no First Blank Option
Display Order: (Whatever ends up being 2nd)
Field Required: Yes, Always
Field Editable by User: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: No
Allow user to input their own value for this option: No
Max length of allowed user input: 100
Field Length: 25
Regular Expression:
Which page displays this option?: Options: Other

---

Title: Custom Avatar URL
(field8 in my examples)
Profile Field Type: Single-Line Text Box
Options: Editable
Description: Type in the URL to your custom avatar. The URL must start with http:// and the avatar must end in .gif, .jpg or .png. For example: http://www.example.com/avatars/avatar.gif
Default Value:
Max length of allowed user input: 100
Field Length: 50
Profile Field Type: Single-Line Text Box
Display Order: (Whatever ends up being 3rd)
Field Required: No
Field Editable by User: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: No
Regular Expression: ^http://([A-Za-z0-9/.~_-]+)\.(jpg|gif|png)$|^$
Which page displays this option?: Options: Other

---

Title: Custom Avatar Width
(field9 in my examples)
Profile Field Type: Single-Line Text Box
Options: Required, Editable
Description: Custom avatar width in pixels (20-120, default 80)
Default Value: 80
Max length of allowed user input: 3
Field Length: 3
Profile Field Type: Single-Line Text Box
Display Order: (Whatever ends up being 4th)
Field Required: Yes, Always
Field Editable by User: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: No
Regular Expression: ^([2-9][0-9]|1[0-1][0-9]|120)$
Which page displays this option?: Options: Other

---

Title: Custom Avatar Height
(field10 in my examples)
Profile Field Type: Single-Line Text Box
Options: Required, Editable
Description: Custom avatar height in pixels (20-120, default 80)
Default Value: 80
Max length of allowed user input: 3
Field Length: 3
Profile Field Type: Single-Line Text Box
Display Order: (Whatever ends up being 5th)
Field Required: Yes, Always
Field Editable by User: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: No
Regular Expression: ^([2-9][0-9]|1[0-1][0-9]|120)$
Which page displays this option?: Options: Other

Step 2: Create a web accessable folder to house your default avatars.
ie. http://www.example.com/avatars/

Step 3: Name and upload the default avatars. You should not use spaces and I suggest using capital letters to distinguish words. This makes it look nicer later on. All your avatars need to have the same file extension, this is currently .gif but can be changed.
ie. OrangeBanana.gif

Step 4: One per line in the Default Avatar field, type in the names of the uploaded avatars exactly as they are, but without the extension.
ie. OrangeBanana.gif = OrangeBanana

Step 5: In Member Info Templates -> MEMBERINFO
Find:
PHP Code:
<if condition="$show['avatar']">
  <
td><img src="$userinfo[avatarurl]$userinfo[avatarsizealt="<phrase 1="$userinfo[username]">$vbphrase[xs_avatar]</phrase>" border="0" style="border:1px solid $stylevar[tborder_bgcolor]; border-top:none" /></td>
<else />
  <
td>&nbsp;</td>
</if> 
Replace:
PHP Code:
<td>
  <if 
condition="$bbuserinfo[options] & 2 OR $bbuserinfo['userid'] == 0">
    <if 
condition="$userinfo['field6'] == 'Default' AND $userinfo['field7']">
      <
img src="http://www.example.com/avatars/$userinfo[field7].gif"  alt="$post[field7]style="border:1px solid $stylevar[tborder_bgcolor]; border-top:none" />
    </if>
    <if 
condition="$userinfo['field6'] == 'Custom' AND $userinfo['field8'] AND $userinfo['field9'] AND $userinfo['field10']">    
      <
img src="$userinfo[field8]alt="" width="$userinfo[field9]height="$userinfo[field10]style="border:1px solid $stylevar[tborder_bgcolor]; border-top:none" />
    </if>
  </if>
&
nbsp;</td
Be sure to replace http://www.example.com/avatars/ with your default avatar location and update all custom fields!

Step 6: In Postbit Templates - > postbit
Skip this step or make your own modification based on my postbit_legacy example. I will include this step later.
The code you want to replace is here:
PHP Code:
<if condition="$show['avatar']"><td class="alt2"><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$post[avatarurl]$post[avwidth$post[avheightalt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a></td></if> 

Step 7: In Postbit Templates - > postbit_legacy
Find:
PHP Code:
<if condition="$show['avatar']">
  <
div class="smallfont">
  &
nbsp;<br /><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$post[avatarurl]$post[avwidth$post[avheightalt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a>
  </
div>
</if> 
Replace:
PHP Code:
<if condition="$bbuserinfo[options] & 2 OR $bbuserinfo['userid'] == 0">
  <if 
condition="$post['field6'] == 'Default' AND $post['field7']">
    <
div class="smallfont">
    &
nbsp;<br />
    <
img src="http://www.example.com/avatars/$post[field7].gif"  alt="$post[field7]border="0" />
  </
div>
  </if>
  <if 
condition="$post['field6'] == 'Custom' AND $post['field8'] AND $post['field9'] AND $post['field10']">    
    <
div class="smallfont">
    &
nbsp;<br />
    <
img src="$post[field8]alt="" border="0" width="$post[field9]height="$post[field10]/>
    </
div>
  </if>
</if> 
Be sure to replace http://www.example.com/avatars/ with your default avatar location and update all custom fields!

Step 8: Run these SQL queries

UPDATE userfield
SET field6 = 'None'
WHERE field6 = ''

UPDATE userfield
SET field7 = 'Avatar'
WHERE field7 = ''
(Replace Avatar with the first default avatar you have in the list)

UPDATE userfield
SET field9 = '80'
WHERE field9 = ''

UPDATE userfield
SET field10 = '80'
WHERE field10 = ''

Step 9: TEST! TEST! TEST!

Revision history:
0.1 BETA
Original release

0.11 BETA
Bugfix: Regular expression for Custom Avatar Width and Height not allowing sizes 100-109. New expression: ^([2-9][0-9]|1[0-1][0-9]|120)$

Special thanks go to Jake Bunce and Viper007Bond who both helped when I was stuck.

Download

No files for download.


vblts.ru supports vBulletin®, 2022-2024