Remote Avatars
This modification is in the archives.
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']">
PHP Code:
<td>
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[avheight] alt="<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']">
PHP Code:
<if condition="$bbuserinfo[options] & 2 OR $bbuserinfo['userid'] == 0">
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. |