Resource icon

avatar.php 1.1.2a

No permission to download
I tried to make a route, create a Router class, a ControllerPublic class but I don't how to return avatar data to browser. Other add-on usually use responseView method to return a template.

There is no need to rewrite this to use a controller and view. It works fine as is. It's a very simple script.
 
QUESTION:
Could you give some quick instructions on how to install this code for Wordpress comments ?

I've got it so that you're logged into xenforo and wordpress simultaneously with the same username. So it would be cool that when they post a comment in wordpress, it would grab their xenforo Avatar.

Is that possible with your code, and can you give just a really quick 'n dirty guide to install it for that purpose?
 
QUESTION:
Could you give some quick instructions on how to install this code for Wordpress comments ?

I've got it so that you're logged into xenforo and wordpress simultaneously with the same username. So it would be cool that when they post a comment in wordpress, it would grab their xenforo Avatar.

Is that possible with your code, and can you give just a really quick 'n dirty guide to install it for that purpose?

If the user_id or username is available then you can use that to call the avatar. Presumably the articles at least have the username available as a variable. The example usage applies::

Code:
<img src="avatar.php?userid=3" />
<img src="avatar.php?userid=3&size=s" />
<img src="avatar.php?username=admin" />
<img src="avatar.php?username=admin&size=l" />

If there is a username variable it might be something like this in the templates:

Code:
<img src="avatar.php?username={$username}" />
 
Wordpress integration question:

Do you have any idea what PHP file in wordpress do I add the
Code:
<img src="avatar.php?username=admin" />
to?

Presumably there is a HTML template in Wordpress where you can enter that code. But I am not familiar with the backend of Wordpress.
 
It is especially useful when you need to display avatars on external pages that are not part of XenForo.

My website has the main site with Joomla, the forum with xenForo, and finally a wiki with WikiMedia. So yeah, 3 three entities all with their own codes and issues.

So to put this in childish terms so that I can understand it better, are you saying that I can use this code:

PHP:
<img src="avatar.php?userid=3" />
<img src="avatar.php?userid=3&size=s" />
<img src="avatar.php?username=admin" />
<img src="avatar.php?username=admin&size=l" />

In the forum footer. And this code:

Code:
<img src="avatar.php?userid=3" />

On a Joomla bio page for my staff members and that in the staff page it will "GET" their forum Avatar?
 
Great add-on, I use it on wodrpress and it work fine! I small modified it and added GET param e-mail: avatar.php?email=test@test.ru... and added url target for comment writer on his member page on forum.
Big thanks Jake Bunce!

p.s. sorry for my english
 
This would be great to be developed into a wordpress plugin to replace comment avatars in wordpress. People would certainly pay for that!
 
Trying to figure this out. So I uploaded the php into my forum root. Now I want to display the Avatar on my homepage so I put in this code:
Code:
<img src="avatar.php?userid=2" />
Is that it? What am I doing wrong?
 
Trying to figure this out. So I uploaded the php into my forum root. Now I want to display the Avatar on my homepage so I put in this code:
Code:
<img src="avatar.php?userid=2" />
Is that it? What am I doing wrong?

What directory is XF installed in? To remove any doubt you can specify the full web path, including the directory name. Example:

Code:
<img src="/forum/avatar.php?userid=2" />
 
Avatars are not showing for me, despite having installed the avatar.php. For example, this, gives a result of 'An unexpected error occurred. Please try again later.', and ACP server error log says 'ErrorException: filesize(): stat failed for ./https://netrider.r.worldssl.net/data/avatars/m/36/36966.jpg - avatar.php:89'

Any thoughts?

It appears you have overridden the default "externalDataUrl" setting in your library/config.php file? This avatar.php file expects the default value of 'data', or a relative path like that. It is not necessarily correct for it to expect a relative path though.

In your case edit this piece of code in the avatar.php file. Remove the red code, add the blue code:

Rich (BB code):
// CUSTOM AVATARS
if (!empty($user['avatar_date']))
{
	$avaurl = XenForo_Template_Helper_Core::getAvatarUrl($user, $size, 'custom');
	
	$group = floor($user['user_id'] / 1000);
	$avaurl = "data" . "/avatars/$size/$group/$user[user_id].jpg?$user[avatar_date]";

	$file = './' . substr($avaurl, 0, strpos($avaurl, '?'));
	$type = 'image/jpeg';
	header('Content-Type:'.$type);
	header('Content-Length: ' . filesize($file));
	readfile($file);

	exit(0);
}

That should fix your problem. This simply inlines the function with the expected relative data path.
 
It appears you have overridden the default "externalDataUrl" setting in your library/config.php file?
Yes, for CDN support ....
Code:
// CDN support
$config['externalDataUrl'] = 'https://netrider.r.worldssl.net/data';

Thanks, appreciate the assistance and code update. Working without error now.
 
Top Bottom