• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Avatar URL


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:


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.

Jake Bunce

XenForo moderator
Staff member
0 is the directory for the first 1000 user_ids. Refer to this 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:


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.


Active member
Thanks for the reply! I'm going to mess with this soon and let you know.

Edit: I used floor() and rounded off, works great!