agison
Well-known member
Why do you need a route? A proper route seems unnecessary to me.
It's fine to use ?userid=123. I just want a route for better browser/cdn caching and for learning.
Thank you.
Why do you need a route? A proper route seems unnecessary to me.
Yes that's fine.
But browser caching doesn't currently work anyways. I still need to test some fixes:
http://xenforo.com/community/threads/caching-problem-with-my-avatar-script.31190/
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.
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?
<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" />
<img src="avatar.php?username={$username}" />
<img src="avatar.php?username=admin" />
Wordpress integration question:
Do you have any idea what PHP file in wordpress do I add theto?Code:<img src="avatar.php?username=admin" />
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.
<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" />
<img src="avatar.php?userid=3" />
...and that in the staff page it will "GET" their forum Avatar?
Apparently "try this later" meant try this over a year later. Is this still going to work on the latest XenForo?Oh I like that, I have to try this later.
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:
Is that it? What am I doing wrong?Code:<img src="avatar.php?userid=2" />
<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?
// 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);
}
Yes, for CDN support ....It appears you have overridden the default "externalDataUrl" setting in your library/config.php file?
// CDN support
$config['externalDataUrl'] = 'https://netrider.r.worldssl.net/data';
We use essential cookies to make this site work, and optional cookies to enhance your experience.