![]() |
customized avatar system
I have a customized avatar system that stores custom avatars as the users username.gif
Now In the postbit template I would like to be able to display that avatar $userinfo[username].gif when I use this i get a broken link if the user hasn't uploaded there avatar yet. I made it so it would load a transparent gif and stuck the gif into a table as a background but it repeats if it isn't 66x64. So what would be the best way to check if the file exists and display it and if not just display the transparent image and fill where the avatar would be? This does not use vB's avatar field so simply checking the usersinfo on the user won't work. Thanks |
if (file_exists("some.file")==1) {
doStuff(); } |
This should work if I have the hack that allows me to use php in the templates?
|
you'll have to hack functions.php
or i think a htaccess way will work to, like a 404 error just if an img file doesn't exists use another one, but i don't know if this really possible, i just think so ;) |
in admin/functions.php
find: if ($post[avatarid]!=0) { $avatarurl=$post[avatarpath]; } else { if ($post[hascustomavatar] and $avatarenabled) { $avatarurl="avatar.php?userid=$post[userid]&dateline=$post[avatardateline]"; } else { $avatarurl=""; } } comment that out and put: if ((file_exists("$userinfo[username].gif ")==1) && $avatarenabled) { $avatarurl="$userinfo[username].gif"; } else { $avatarurl=""; } } you should then not have to make any template changes at all from the original to display this avatar instead. remember to get rid of the !($bbuserinfo[showavatars]) bit on the line below it if you havent tied this system in with the users showavatar variable. forgive any errors... been up for 2 days with a busted jaw :( hope that helps :) |
Thanks for all the responses. I ended up figuring this out with my old code that I had for the avatar system, with some assistance from another person who was up at 4:30 am in the vB chatroom :)
|
All times are GMT. The time now is 12:39 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|