Log in

View Full Version : Show avatar code?


Rocc
07-14-2008, 08:11 AM
I'm working on my website right now, I need the avatar code
And the lastest 5 posts or more code would help also...

--------------- Added 1216033719 at 1216033719 ---------------

Anyone please....

Dismounted
07-14-2008, 11:03 AM
Use the fetch_avatar_url() function.

SLR722
07-14-2008, 02:53 PM
Can this be declared in vB templates? ForumHome for example? fetch_avatar_url()

Dismounted
07-15-2008, 09:45 AM
No - it cannot be used in templates.

Opserty
07-15-2008, 03:40 PM
You could try: Avatar On Navbar (https://vborg.vbsupport.ru/showthread.php?t=99498&highlight=avatar+navbar) and move the template code from the navbar template to wherever you need it.

SLR722
07-15-2008, 06:48 PM
How do I call a member avatar through templates?

Opserty
07-15-2008, 07:38 PM
Look at the modification I posted... see the code they used.

I didn't post it just randomly! :D

SLR722
07-15-2008, 08:42 PM
I am looking for a Show Online Avatars list for the who is online..

Dismounted
07-16-2008, 10:04 AM
You could try: Avatar On Navbar (https://vborg.vbsupport.ru/showthread.php?t=99498&highlight=avatar+navbar) and move the template code from the navbar template to wherever you need it.
There is now a much simpler code that can be used - and without the cost of additional queries :). I found out accidentally when looking through a file.

SLR722
07-16-2008, 10:40 AM
Any chance of the code? :cool:

Was thing of calling MySQL, and getting all online members and then where each member has an avatar display and if they do not, dont show them up as online in the box.

Dismounted
07-16-2008, 11:00 AM
It would not fit in your situation - I was only referring to fetching an avatar for the current logged in user.

mof9336
07-16-2008, 11:38 AM
dont know if this code may help.


require_once('./includes/functions_user.php');
$navbar_ava = fetch_avatar_url($vbulletin->userinfo['userid']);
if (!is_array($navbar_ava))
{
$navbar_ava[] = $vbulletin->options['bburl'] . "/images/misc/noavatar.gif";//this will display a noavatar image if no avatar is used.
}


the $vbulletin->userinfo['userid'] will return the current logged in user but you can use any userid here.

call with
<img src="$navbar_ava[0]">
in the template

Fraik
07-16-2008, 02:17 PM
It would not fit in your situation - I was only referring to fetching an avatar for the current logged in user.

Could you share the code please. I am looking to display the user's current avatar, but the code I used on my 3.6 forums before no longer works on 3.7 :(

SLR722
07-16-2008, 06:54 PM
Could you share the code please. I am looking to display the user's current avatar, but the code I used on my 3.6 forums before no longer works on 3.7 :(

Hey man. What are you using to run MEC. Thats an amazing site, really like it alot especially the homepage :up:

Fraik
07-16-2008, 06:59 PM
Thanks... I'm using vBulletin and Wordpress (currently at 3.6, testing 3.7 /w avatar issues) with the Wordpress/vBulletin mod from here - and a boatload of other smaller plugins.

Dismounted
07-18-2008, 07:37 AM
Could you share the code please. I am looking to display the user's current avatar, but the code I used on my 3.6 forums before no longer works on 3.7 :(
Look in class_core.php (vB_Session class constructor).

SLR722
07-20-2008, 12:10 PM
Can I do something like this


START PHP
INCLUDE VB GLOBAL FILES
INCLUDE VB USER FILES
ECHO HTML IMAGE OF AVATAR
ELSE
ECHO HTML IMAGE OF BLANK AVATAR
END IF
END PHP


Could I do this on an external vB page.

<img src="$vB->avatar_of_user.$extension" alt="" border="" />

And its not only if they are logged in, it will always show the avatar of a user pulling from a forum

Dismounted
07-20-2008, 12:12 PM
See the fetch_avatar_url() function.

SLR722
07-20-2008, 04:12 PM
Its not in class_core.php

fetch_avatar_url()

Can you please tell me where it is and an example of how to call it?

fetch_avatar_url($user="$user");

Dismounted
07-21-2008, 06:17 AM
The reference to class_core.php by me was for putting the avatar in the navbar. I would suggest getting a mass search program to help you find things like this in files.

See the vBulletin API (http://members.vbulletin.com/api/).

SLR722
07-21-2008, 07:25 PM
Is there a modification that shows the avatars of the people online? Do you do custom work?

Dismounted
07-22-2008, 07:28 AM
No, I don't believe there are any modifications that do this. And no, I am currently not available for custom work.

carmichael1973
07-27-2008, 04:37 PM
Its not in class_core.php

fetch_avatar_url()

Can you please tell me where it is and an example of how to call it?

fetch_avatar_url($user="$user");

I'm not sure what all the secrets are about? You just need to become familiar with the following bit of code:

This will call a users avatar:
<img src="$vboptions[bbdir]/image.php?u=$bbuserinfo[userid]" alt="Your avatar" border="0" />

and this is what I use in place of the Avatar in Navbar mod:

In navbar template replace:

<table cellpadding="0" cellspacing="0" align="left" style="margin-top:5px;">
<tr>
<td><a href="profile.php?$session[sessionurl]do=editavatar"><img src="$navbar_ava[0]" alt="Your avatar" border="0" /></a>
</td>

with this:

<table cellpadding="0" cellspacing="0" align="left" style="margin-top:5px;">
<tr>
<td><a href="$vboptions[bbdir]/profile.php?$session[sessionurl]do=editavatar"><img src="$vboptions[bbdir]/image.php?u=$bbuserinfo[userid]" alt="Your avatar" border="0" /></a>
</td>

In non-vb pages (I use vbPortal) I use this code:

<table cellpadding="0" cellspacing="0" align="left" style="margin-top:5px;">
<tr>
<td><a href="$vbpoptions[bbdir]/profile.php?$session[sessionurl]do=editavatar"><img src="$vbpoptions[bbdir]/image.php?u=$bbuserinfo[userid]" alt="Your avatar" border="0" /></a>
</td>

Then just simply assign the noavatar.gif as the default avatar for your usergroups. From then on your users that have not uploaded a custom avatar will be displayd the noavatar.gif

Personally I don't use the no avatar image as the default. I created a custom default avatar for each usergroup.

As for the plugin for the original Avatar on Navbar mod, I don't even use it. With this bit of code it's simple and not needed.

or if you want to call it directly using an http: use this method:

<table cellpadding="0" cellspacing="0" align="left" style="margin-top:5px;">
<tr>
<td><a href="http://www.yourwebsite/pathtoforums/profile.php?$session[sessionurl]do=editavatar"><img src="http://www.yourwebsite/pathtoforums/image.php?u=$bbuserinfo[userid]" alt="Your avatar" border="0" /></a>
</td>

The user must be logged in to the forums and using cookies to work outside of the forum root. If you are using an integrated portal system you should have no issues!

Enjoy!

Dismounted
07-28-2008, 07:04 AM
This will call a users avatar:
<img src="$vboptions[bbdir]/image.php?u=$bbuserinfo[userid]" alt="Your avatar" border="0" />
If avatars are stored in the database only ;).

carmichael1973
07-28-2008, 11:14 PM
If avatars are stored in the database only ;).

Mine are stored in the file system and it works just fine!

"Attachments are currently being stored in the filesystem at C:\Inetpub\advtech\attachments"

Dismounted
07-29-2008, 07:01 AM
Can you explain to me how it does not work here (my avatar using your format (https://vborg.vbsupport.ru/image.php?u=86103)), or one of my forums either (here (http://www.muffinshare.net/image.php?u=1))?

Also see these lines in image.php - they "fetch" the avatar from the database, but "filedata" is empty if avatars are stored in the filesystem.
if ($imageinfo = $db->query_first_slave("
SELECT $filedata, dateline, filename
FROM " . TABLE_PREFIX . "$table
WHERE userid = " . $vbulletin->GPC['userid'] . " AND visible = 1
HAVING filedata <> ''
"))
}