View Full Version : Customizing VSa - Chatbox with user avatars
MarkFL
12-08-2014, 10:00 PM
How to display user avatars. We use the file system to store our avatars, so could not use the image.php?u=userid method.
To show avatars open the plugin titled "VSa - ChatBox - MN" and locate the line:
$vsacb_msg_box_parsed = str_replace('\'', ''', $vsacb_bbparser->do_parse($vsacb_msg_box_styled,1,$vsacb_smilies_on off,1,1,1));
And after that, inserted the code:
require_once('./includes/functions_user.php');
$avatar_url = fetch_avatar_url($vsacb_msg_box['userid']);
$avatar = $avatar_url[0];
if (!$avatar)
{
$avatar = './images/misc/unknown.gif';
}
$user_avatar = '<img src="'.$avatar.'" border="0" width="48" style="vertical-align: middle" />';
vB_Template::preRegister('vsa_chatbox_bit',array(' user_avatar' => $user_avatar));
Save the plugin, and then in the template "vsa_chatbox_bit" you may use "{vb:raw user_avatar}" to display the user avatars. :cool:
MarkFL
12-12-2014, 12:54 AM
Hello all,
I am using vBulletin 4.2.1 on my local server as my dev site, and once done, I will go live with this on the forum I help administrate which runs vBulletin 4.2.2 patch level 2.
I am doing some custom hacks to Valter's great chatbox, and I am stumped on how to display user avatars. We use the file system to store our avatars, so I cannot use the image.php?u=userid method.
So, I have written a plugin, hook location is parse_templates, with the plugin PHP code:
require_once('./includes/functions_user.php');
$avatar_url = fetch_avatar_url($vbulletin->userinfo[$vsacb_msg_box.userid]);
$avatar = $avatar_url[0];
$user_avatar = '<img src="'.$avatar.'" border="0" width="40" style="vertical-align: middle" />';
vB_Template::preRegister('vsa_chatbox_bit',array(' user_avatar' => $user_avatar));
Now, what I get is my avatar in every posted message, instead of the avatars of the users who actually posted the various messages. Can anyone tell me what I am missing?
I found the solution to my problem! :D
Instead of creating a new plugin, I hacked an existing one. I opened the plugin titled "VSa - ChatBox - MN" and located the line:
$vsacb_msg_box_parsed = str_replace('\'', ''', $vsacb_bbparser->do_parse($vsacb_msg_box_styled,1,$vsacb_smilies_on off,1,1,1));
And after that, inserted the code:
require_once('./includes/functions_user.php');
$avatar_url = fetch_avatar_url($vsacb_msg_box['userid']);
$avatar = $avatar_url[0];
if (!$avatar)
{
$avatar = './images/misc/unknown.gif';
}
$user_avatar = '<img src="'.$avatar.'" border="0" width="48" style="vertical-align: middle" />';
vB_Template::preRegister('vsa_chatbox_bit',array(' user_avatar' => $user_avatar));
Save the plugin, and then in the template "vsa_chatbox_bit" you may use "{vb:raw user_avatar}" to display the user avatars. :cool:
Lynne
12-12-2014, 01:22 AM
Thank you for posting the solution to your problem. Hopefully it will help someone else who has the same issue.
chikuru
12-12-2014, 04:27 AM
Thank you for this! I was also trying to code this.
TheLastSuperman
05-02-2016, 06:56 PM
Moved to articles :cool:. Also made second post the first post then pasted old first post code into second with strike-through - for reference only ;).
GHRake
05-08-2016, 03:00 PM
This is an awesome article, thank you!
In the img tag I set height="20" width="20" and it looks great with 14px text height
https://vborg.vbsupport.ru/external/2016/05/26.png
And if anyone was wondering where to place {vb:raw user_avatar} inside the vsa_chatbox_bit template, find:
{vb:raw vsacb_msg_box.musername}
And replace with:
{vb:raw user_avatar} {vb:raw vsacb_msg_box.musername}
MarkFL
05-08-2016, 03:13 PM
I kind of went wild when I was learning javascript and made quite a few changes to the chat:
https://vborg.vbsupport.ru/attachment.php?attachmentid=154970&stc=1&d=1462727590
GHRake
05-09-2016, 02:05 AM
I kind of went wild
Yes you did! Site looks great BTW
MarkFL
05-09-2016, 02:09 AM
Yes you did! Site looks great BTW
Thank you! The style was done by a hired designer, and we have added a lot of bells and whistles. :D
BliNeR-KeY
05-20-2016, 03:59 PM
i use
https://vborg.vbsupport.ru/showthread.php?t=268618
i cant set 20x20
.tile_avatar {
width: 80px;
height: 80px;
background: #ef7600;
text-align: center;
maybe you have code only for chatbox ?
MarkFL
05-20-2016, 04:04 PM
This article is about adding avatars to "VSa - Chatbox" not to the forumdisplay or other areas. :)
BliNeR-KeY
05-20-2016, 04:14 PM
pls check is so big 80x80
http://prntscr.com/b6ezvd
i just add
{vb:raw user_avatar} {vb:raw vsacb_msg_box.musername}
MarkFL
05-20-2016, 04:55 PM
Change this line:
$user_avatar = '<img src="'.$avatar.'" border="0" width="48" style="vertical-align: middle" />';
to suit your needs. :)
BliNeR-KeY
05-20-2016, 05:07 PM
thank you so much fixed
$user_avatar = '<img src="'.$avatar.'" border="20" width="20" style="vertical-align: middle" />';
see
http://prntscr.com/b6fqys
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.