Avatar URL

grantus

Active member
I'm trying to display my members' avatars on my own PHP page (non-xf) but the only thing that's stopping me is this one thing. Here's an example URL:

mysite.com/forums/data/avatars/m/0/1.jpg?1340366835

So all I need to know is where does the '0' come from (after the m/)? I looked into the xf_user table but not sure if it's from there. I know 'm' is for the size but I'm stumped on the '0'.

Any help would be appreciated. Thanks.
 
0 is the directory for the first 1000 user_ids. Refer to this code:

library/XenForo/Template/Helper/Core.php

Code:
	protected static function _getCustomAvatarUrl(array $user, $size)
	{
		$group = floor($user['user_id'] / 1000);
		return XenForo_Application::$externalDataUrl . "/avatars/$size/$group/$user[user_id].jpg?$user[avatar_date]";
	}

This script might be useful to you:

http://xenforo.com/community/resources/avatar-php.634/

This script is very convenient for showing avatars, but it does represent one database query for each request which might be a concern if the page is high traffic.
 
Top Bottom