Other [PAID] PHP script to display an avatar via URL

TimeWizardCosmo

Well-known member
Here's what I'm trying to accomplish:
http://xenforo.com/community/threads/getting-an-avatar-from-a-url.30703/

Basically, I need to be able to do this:
HTML:
<img src="http://mysite.com/avatar.php?uid=1&size=s" />
AND/OR
HTML:
<img src="http://mysite.com/avatar.php?user=Cosmo&size=s"/>

And have it display this:
670.jpg


The script would need to be able to provide the ability to display the appropriate size depending on the string in the URL; small, medium or large.

The script should also be able to display Gravatars if they're being used, or a fallback image if no avatar exists.

Jake Bunce probably already got me halfway with this post, but I'm not familiar enough with any of this to work it out myself in a reasonable amount of time.

Willing to throw a few bucks at this via PayPal if anyone is interested. I also won't mind sharing the file so others can benefit, if that makes a difference.

Thanks.
 
I am trying to figure out what you are trying to do, where do you want to display the avatar? Inside a post?
 
I am trying to figure out what you are trying to do, where do you want to display the avatar? Inside a post?

I'm going to use it to display user avatars in AddonChat. The message template right now is:
HTML:
<table border=0 cellpadding=0 cellspacing=3><tr><td valign=top align=left>$avatar</td><td align=left valign=top>$time $username:<br>$message</td></tr></table>

The $avatar bit just calls AddonChat's own crappy avatars. What I want to do is replace that with:
HTML:
<img src="http://mydomain.com/avatar.php?uid=$uid&size=s" />
so that it shows user avatars from my site.

What I need is the avatar.php script written by someone so it can produce the image. Since AddonChat can't hook in to xenForo's logic/mechanics, this is the only way I found that will work.

Hopefully that makes sense, let me know if I'm explaining it poorly.
 
You need your software, whatever it is, to initialize xenforo and then you can use the code which Jake pointed you to. But ya, you will probably need someone with experience if you haven't done it before.
 
You need your software, whatever it is, to initialize xenforo and then you can use the code which Jake pointed you to. But ya, you will probably need someone with experience if you haven't done it before.

Addonchat has no way of doing this; the only thing you can edit inside Addonchat's templates is the HTML used to display the chat message. The script inside the image tag needs to initialize xenForo.
 
Here's what I'm trying to accomplish:
http://xenforo.com/community/threads/getting-an-avatar-from-a-url.30703/

Basically, I need to be able to do this:
HTML:
<img src="http://mysite.com/avatar.php?uid=1&size=s" />
AND/OR
HTML:
<img src="http://mysite.com/avatar.php?user=Cosmo&size=s"/>

And have it display this:
670.jpg


The script would need to be able to provide the ability to display the appropriate size depending on the string in the URL; small, medium or large.

The script should also be able to display Gravatars if they're being used, or a fallback image if no avatar exists.

Jake Bunce probably already got me halfway with this post, but I'm not familiar enough with any of this to work it out myself in a reasonable amount of time.

Willing to throw a few bucks at this via PayPal if anyone is interested. I also won't mind sharing the file so others can benefit, if that makes a difference.

Thanks.
i dont have any knowledge about addonchat but if you want show XenForo's users' avatar (which is local or gravatar) via using another page, i can write it (just using userId)
please send me pm for demo file if u interested
 
PHP:
<?php
 
class Misc_Avatar
{
 
    public function actionIndex($username, $size = 'm')
    {
        $user        = XenForo_Model::create('XenForo_Model_User');
        $me        = $user->getUserByName($username);
        $avatarUrl    = XenForo_Template_Helper_Core::callHelper('avatar', array($me, $size, null, true));
       
        header("Cache-Control: max-age=7200");
        header("Expires: \"".date(DATE_RFC822,strtotime("+2 hours"))."\"");
        header("location: $avatarUrl");
        exit;
    }
 
}

Just hook this controller up to a prefix and you're done.
 
without avatar it's already available in vanilla xenforo http://xenforo.com/community/members/ragtek.82/ministats.xml

you could include the avatar url too and include it as image on client side
XenForo_ControllerPublic_Member
PHP:
public function actionMiniStats()
{
$userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
$user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userId);
 
$user = XenForo_Application::arrayFilterKeys($user, array(
'user_id',
'username',
'message_count',
'like_count',
'trophy_points',
'register_date',
));
 
$viewParams = array('user' => $user);
 
return $this->responseView('XenForo_ViewPublic_Member_MiniStats', '', $viewParams);
}
 
Here's what I'm trying to accomplish:
http://xenforo.com/community/threads/getting-an-avatar-from-a-url.30703/

Basically, I need to be able to do this:
HTML:
<img src="http://mysite.com/avatar.php?uid=1&size=s" />
AND/OR
HTML:
<img src="http://mysite.com/avatar.php?user=Cosmo&size=s"/>

And have it display this:
670.jpg


The script would need to be able to provide the ability to display the appropriate size depending on the string in the URL; small, medium or large.

The script should also be able to display Gravatars if they're being used, or a fallback image if no avatar exists.

Jake Bunce probably already got me halfway with this post, but I'm not familiar enough with any of this to work it out myself in a reasonable amount of time.

Willing to throw a few bucks at this via PayPal if anyone is interested. I also won't mind sharing the file so others can benefit, if that makes a difference.

Thanks.
Shoot me a PM, If your still interested.
 
Top Bottom