View Full Version : Miscellaneous Hacks - Place Avatar in VB and Non-VB Pages
carmichael1973
07-26-2008, 10:00 PM
The following is a bit of code I came up with to continue to use the Avatar in Navbar mod by fraghappy. After searching for many hours I decided just to figure it out myself.
On the bright side, none of the plugins and db queries from the old mod are used.
I'll try to support this as much as possible, but I don't foresee anyone having any real issues. It's pretty straight forward.
Don't forget to click the INSTALL (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=186493)
Features in progress
Add Auto-Resize for Navbar Only
Add AJAX function to expand to original size on mouse over
Definable default no avatar images for usergroups
AdminCP Options
Build as a simple product
You just need to become familiar with the following bit of code:
This will display 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.e. vbp_navbar I use vbPortal) I use this code: You must modify this to match your portal or external pages
<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 displayed 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!
07/28/2008 - Added simple screenshot.
FReeSTER
07-27-2008, 05:17 PM
Thank you very much, But I have one question, for those who have Big Avatars will this Mod resize the Avatar for what ever pixels want it?
Thank you </installed>
carmichael1973
07-27-2008, 05:25 PM
My attempts to contact the author of Show User's Avatar in Navbar v1.1 (https://vborg.vbsupport.ru/showthread.php?t=83053), fraghappy have been unsuccessful. I'll try to make this into a product with <if> functions to call a default avatar if no custom avatar exists.
None of the original authors code is needed using this method so there shouldn't be an issue!
carmichael1973
07-27-2008, 05:33 PM
Thank you very much, But I have one question, for those who have Big Avatars will this Mod resize the Avatar for what ever pixels want it?
Thank you </installed>
No it doesn't! I am working on adding the resize image function just like when you add a custom avatar through the admincp. At this point I advertise max avatar sizes. My users have been pretty good about resizing thier own images.
I'd like to have it resize just for the navbar only and then add some ajax function to it so that it expands on mouse over.
I'll keep everyone posted on the progress!
FReeSTER
07-27-2008, 05:49 PM
No it doesn't! I am working on adding the resize image function just like when you add a custom avatar through the admincp. At this point I advertise max avatar sizes. My users have been pretty good about resizing thier own images.
I'd like to have it resize just for the navbar only and then add some ajax function to it so that it expands on mouse over.
I'll keep everyone posted on the progress!
Thank you mate, very nice of you
zmmmzz
07-28-2008, 04:28 PM
super cool mod
RobbieZ
07-28-2008, 04:51 PM
Can we see a demo please..
zmmmzz
07-28-2008, 05:38 PM
Then just simply assign the noavatar.gif as the default avatar for your usergroups
How do I do this?
Cant wait for the resize image function.
carmichael1973
07-28-2008, 10:52 PM
How do I do this?
Cant wait for the resize image function.
1) First Create a separate Avatar Category for each Usergroup:
In your admincp go to Avatars> Avatar Manager> Create New Avatar Category
2) Go to Avatars> Avatar Manager> (Usergroup Category) Avatar Permissions and select "No" for all usergroups except "Administrators" and the usergroup you setup the category for.
Repeat this step for all the other Usergroup Categories you made.
3) Go to Avatars> Upload Avatar and select the image you use as your "NoAvatar" image. Set the Minimum Posts field to "0" and select the category that will use it. Give it a Title and click UPLOAD.
Note: You can use the same image for each usergroup category but you must upload it for each one separately.
Repeat this upload step for each user.
I only use two usergroup categories so and both have individual images.
I hope this helps you out!
zmmmzz
07-29-2008, 03:15 AM
thanks for the explanation!
now I'm trying to set an avatar as default so that when a user registers the avatar is already selected in his or her account instead of 'no avatar specified'.
Is this possible?
carmichael1973
07-29-2008, 03:32 AM
thanks for the explanation!
now I'm trying to set an avatar as default so that when a user registers the avatar is already selected in his or her account instead of 'no avatar specified'.
Is this possible?
It is possible.... If you can give me another couple of days I'll have a total solution for you. Then the above steps won't be needed. I'm very close on this but work is taking alot of my time.
zmmmzz
07-29-2008, 04:21 PM
ok! cant wait
thank you for taking time for this
trulylowcarb
08-04-2008, 05:19 PM
Thank you! I was looking for the right code to display avatars in the navbar. I need them to be smaller, too, though.
*installed*
trulylowcarb
08-04-2008, 06:20 PM
I am sure it is a dirty cheat, but I just used the html to call the avatar directly in my navbar, then added width="25%" height="25%". It seems to work perfectly. For those with no avatar, the space is just blank. I would really like to use the default avatar instead though, I haven't found anything to do that in anything even close to the current version and I have a lot usergroups, so ....
<crossing fingers you'll put it all together for us> :)
trulylowcarb
08-04-2008, 06:33 PM
I take it back - it doesn't update when the avatar is changed or deleted.
MobileBros
08-04-2008, 11:47 PM
My attempts to contact the author of Show User's Avatar in Navbar v1.1 (https://vborg.vbsupport.ru/showthread.php?t=83053), fraghappy have been unsuccessful. I'll try to make this into a product with <if> functions to call a default avatar if no custom avatar exists.
None of the original authors code is needed using this method so there shouldn't be an issue!
https://vborg.vbsupport.ru/showpost.php?p=666619&postcount=8
read that ...... and cant wait for the resize feature either:p
Captain Tycoon
08-09-2008, 11:50 AM
Works nicely! Will let you know if any bugs or problems appear :) marked as installed!
Chris11987
08-14-2008, 07:14 AM
I can't get this to work. put the code in for a non-vb page, and edited the two directories to match my forums, but all I get is an image that says "vbulletin" on it. And clicking the image logs me out of the forums, even though I have cookies enabled and am permanently logged in.
carmichael1973
08-14-2008, 10:23 AM
I can't get this to work. put the code in for a non-vb page, and edited the two directories to match my forums, but all I get is an image that says "vbulletin" on it. And clicking the image logs me out of the forums, even though I have cookies enabled and am permanently logged in.
When you say you "edited the two directories to match your forums", what edits did you make? Can you post the code you are trying to use?
Also, with regards to your cookie issue... What is your "Path to save cookies" and "Cookie Domain" set to in your VB Admin options? Based on your issue, I'm assuming you are using the direct method (i.e. http://www.yourdomain.com/..........). If your cookie path and domain settings are not correct, entering a direct link will cause the user to be logged out.
Let me explain... If I visit http://yourforums.com and login, I'm able to click on other links beginning with the http://yourforums.com and stay logged in. If you direct entry a link as http://www.yourforums.com and your cookie path is not setup to recognize the two as being the same, I will be logged out.
Provide some more info and I'll help you sort it out!
ForgotenDynasty
08-16-2008, 02:25 AM
would this work on a wordpress blog using the wordpress bridge?
odln018
09-18-2008, 01:31 PM
I can't seem to get this operating.
When i try to find the original navbar code for replacement, I'm not seeing it.
I don't want to add a default avatar to all users but I would like to display a default avatar in the navbar when the user is missing one.
could that be done with something like?
<img src="$vboptions/vbtest/image.php?u=$bbuserinfo[userid]" [B]alt="/images/navbaravatar.gif" border="0" />
Another question: The avatars display just fine but when a person without avatar logs in the text "Your avatar" is missing and all there is is a blank space.
Chris11987
11-23-2008, 07:37 AM
I'm trying to place the avatar right next to my "Welcome _____, you have X PMs and notifications" part of the navbar.
Here's my code I'm using, with the avatar part highlighted red:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="alt1" width="300">
<if condition="$show['member']">
<td class="alt2" nowrap="nowrap">
<div class="smallfont">
<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>
<strong><phrase 1="$bbuserinfo[username]" 2="member.php?$session[sessionurl]u=$bbuserinfo[userid]">$vbphrase[welcome_x_link_y]</phrase></strong><br />
<if condition="$show['notifications']">
<div><span id="notifications"><a href="usercp.php$session[sessionurl_q]">$vbphrase[your_notifications]:</a> <strong>$notifications_total</strong></span></div>
<script type="text/javascript"> vBmenu.register("notifications"); </script>
<else /><if condition="$show['pmstats']">
<div><phrase 1="$vbphrase[unread_x_nav_compiled]" 2="$vbphrase[total_x_nav_compiled]" 3="$session[sessionurl_q]">$vbphrase[private_messages_nav]</phrase></div>
</if></if>
<if condition="$show['pmwarning']"><div><strong><phrase 1="$vbphrase[pmpercent_nav_compiled]">$vbphrase[your_pm_box_is_x_full]</phrase></strong></div></if>
</div>
</td>
<else />
<td class="alt2" nowrap="nowrap" style="padding:0px">
<!-- login form -->
<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">
<script type="text/javascript" src="clientscript/vbulletin_md5.js?v=$vboptions[simpleversion]"></script>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr>
<td class="smallfont" style="white-space: nowrap;"><label for="navbar_username">$vbphrase[username]</label></td>
<td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
<td class="smallfont" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />$vbphrase[remember_me]</label></td>
</tr>
<tr>
<td class="smallfont"><label for="navbar_password">$vbphrase[password]</label></td>
<td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" tabindex="102" /></td>
<td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="104" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
</tr>
</table>
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
</form>
<!-- / login form -->
</td>
</if>
</tr>
</table>
I've also tried using:
<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>
I used my website's domain and forums path, of course, and the www's part is not an issue.
Wordplay
11-23-2008, 01:55 PM
if a user doesn't have an avatar though it doesn't show the noavatar pic... matter of fact in the code i also can't see anything saying it should pick out a noavatar pic.
and if a user isn't logged in it shows this image:
https://vborg.vbsupport.ru/image.php?u=0
https://vborg.vbsupport.ru/external/2008/11/1.php?u=0
Chris11987
11-25-2008, 05:26 AM
I'm trying to place the avatar right next to my "Welcome _____, you have X PMs and notifications" part of the navbar.
Here's my code I'm using, with the avatar part highlighted red:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="alt1" width="300">
<if condition="$show['member']">
<td class="alt2" nowrap="nowrap">
<div class="smallfont">
<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>
<strong><phrase 1="$bbuserinfo[username]" 2="member.php?$session[sessionurl]u=$bbuserinfo[userid]">$vbphrase[welcome_x_link_y]</phrase></strong><br />
<if condition="$show['notifications']">
<div><span id="notifications"><a href="usercp.php$session[sessionurl_q]">$vbphrase[your_notifications]:</a> <strong>$notifications_total</strong></span></div>
<script type="text/javascript"> vBmenu.register("notifications"); </script>
<else /><if condition="$show['pmstats']">
<div><phrase 1="$vbphrase[unread_x_nav_compiled]" 2="$vbphrase[total_x_nav_compiled]" 3="$session[sessionurl_q]">$vbphrase[private_messages_nav]</phrase></div>
</if></if>
<if condition="$show['pmwarning']"><div><strong><phrase 1="$vbphrase[pmpercent_nav_compiled]">$vbphrase[your_pm_box_is_x_full]</phrase></strong></div></if>
</div>
</td>
<else />
<td class="alt2" nowrap="nowrap" style="padding:0px">
<!-- login form -->
<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">
<script type="text/javascript" src="clientscript/vbulletin_md5.js?v=$vboptions[simpleversion]"></script>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr>
<td class="smallfont" style="white-space: nowrap;"><label for="navbar_username">$vbphrase[username]</label></td>
<td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
<td class="smallfont" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />$vbphrase[remember_me]</label></td>
</tr>
<tr>
<td class="smallfont"><label for="navbar_password">$vbphrase[password]</label></td>
<td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" tabindex="102" /></td>
<td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="104" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
</tr>
</table>
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
</form>
<!-- / login form -->
</td>
</if>
</tr>
</table>
I've also tried using:
<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>
I used my website's domain and forums path, of course, and the www's part is not an issue.
Anyone?
edit:
After taking a look, it seems that the codes given in this thread are calling whatever the url of the current page is as the image. Since a webpage is obviously not an image, that is why the avatar won't show up. My question is, how did everyone else get theirs to work. I've tried using "$avatarurl" and "$user[avatarurl]" as the image source and still haven't had any luck.
It works on my test site which have vBadvanced and vbulletin files in the same folder(root), but It won't work on my live site where I have vBa inte the root and the forum in /forum
Any idea why?
Chris11987
11-26-2008, 06:59 PM
It works on my test site which have vBadvanced and vbulletin files in the same folder(root), but It won't work on my live site where I have vBa inte the root and the forum in /forum
Any idea why?
I should probably point out that this is the same problem I'm having.
I should probably point out that this is the same problem I'm having.
Would be great with a fix!
Chris11987
12-04-2008, 09:20 AM
I'd like to update by saying that even after moving my compss to inside my forum's directory, I still have no avatar showing up.
Davey-UK
12-29-2008, 12:37 PM
I'd like to update by saying that even after moving my compss to inside my forum's directory, I still have no avatar showing up.
Just add the following in your template and it works fine
<a href="http://www.yourdomain/forumsdir/profile.php?$session[sessionurl]do=editavatar"><img src="http://www.yourdomain/forumsdir/image.php?u=$bbuserinfo[userid]" alt="Your avatar" border="0" /></a>
Obviously change the red bits to your own domain and forums directory.
Cobra-J82
01-05-2009, 02:02 PM
I have 3.7.4
I tried everything u guys said
It just gives blank
BucShot
01-14-2009, 10:43 PM
I'm running 3.8.0 on a test site and only wanted to display a small version of the member's avatar so I streamlined the code to this.
<img width="50" src="$vboptions[bburl]/image.php?u=$bbuserinfo[userid]" alt="Your Avatar" border="0" />
You people running vBa in a different directory will need to edit your header and navbar replacement info in your vBa settings.
thunder_sti
01-24-2009, 07:09 PM
Can someone come up with a fix. I cant manage to install this avatar thingy into my navbar.
unless, the instructions are just confusing.
Can anyone help me ?
Thanks
ViciousCode
02-06-2009, 12:57 PM
there is one thing missing...
what if the user is using a avatar from a different site, for example, from google images
or is using gallery avatars from the images/avatars directory
columbusgeek
04-09-2009, 01:12 AM
A simple tweak.
If you dont want the goofy vbulletin image to come up for guests, simply add:
<if condition="$show['member']"> to the beginning of the code and a </if> to the end of the code. Then the avatar will only show for logged in users.
tomotron
04-13-2009, 11:53 PM
there is one thing missing...
what if the user is using a avatar from a different site, for example, from google images
or is using gallery avatars from the images/avatars directory
This also doesn't seem to work if you store custom avatars in the filesystem as opposed to the database... anyone know a workaround?
The D
04-15-2009, 05:16 AM
This also doesn't seem to work if you store custom avatars in the filesystem as opposed to the database... anyone know a workaround?
I think that may be my problem as well. When I use any of the above codes, it only shows up as a text link 'Your avatar'. I figure it has to do with the filesystem storage type?
If not, I have no idea why it won't work..
ViciousCode
05-08-2009, 10:21 AM
isnt the "&dateline=date" missing?
fourat
07-12-2009, 01:30 AM
if the member not have avatar how i put "noavater.gif" ?
miner
07-30-2009, 03:40 AM
I take it back - it doesn't update when the avatar is changed or deleted.
Yes it happens the same for me, the avatar does not update, but it does change in the postbit!
MarioN70
10-26-2009, 02:17 PM
Excellent post.
thanks.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.