PDA

View Full Version : Customizing VSa - Chatbox with user avatars


MarkFL
09 Dec 2014, 03:25
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_onoff,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 Dec 2014, 02:54
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_onoff,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 Dec 2014, 03:22
Thank you for posting the solution to your problem. Hopefully it will help someone else who has the same issue.

chikuru
12 Dec 2014, 06:27
Thank you for this! I was also trying to code this.

M.C.
02 May 2016, 10:12
thanks, great addon!

TheLastSuperman
02 May 2016, 21:56
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
08 May 2016, 18:00
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://www.vbulletin.org/forum/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
08 May 2016, 18:13
I kind of went wild when I was learning javascript and made quite a few changes to the chat:

http://www.vbulletin.org/forum/attachment.php?attachmentid=154970&stc=1&d=1462727590

GHRake
09 May 2016, 05:05
I kind of went wild

Yes you did! Site looks great BTW

MarkFL
09 May 2016, 05:09
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
20 May 2016, 18:59
i use
http://www.vbulletin.org/forum/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
20 May 2016, 19:04
This article is about adding avatars to "VSa - Chatbox" not to the forumdisplay or other areas. :)

BliNeR-KeY
20 May 2016, 19:14
pls check is so big 80x80
http://prntscr.com/b6ezvd
i just add

{vb:raw user_avatar} {vb:raw vsacb_msg_box.musername}

MarkFL
20 May 2016, 19:55
Change this line:

$user_avatar = '<img src="'.$avatar.'" border="0" width="48" style="vertical-align: middle" />';

to suit your needs. :)

BliNeR-KeY
20 May 2016, 20:07
thank you so much fixed


$user_avatar = '<img src="'.$avatar.'" border="20" width="20" style="vertical-align: middle" />';

see


http://prntscr.com/b6fqys