It does exactly that. I decided to pick the "any" (so it includes all sets) option just in case more robot variants are made in the future.it lumps the three types of Robohash robots into one
While there, you might want to also add "&gravatar=hashed" to the end. That way if any of your users have gravatar avatars then they will be used instead of the RoboHash generated avatar. Without it any of your users that selected to use Gravatar will get a RoboHash avatar instead.I wish there was options for that, but I was able to go in and manually edit the code in listener.php to limit it to one set and add a background so it fits my board's needs.
It already checks to see if a Gravatar is present and serves it if found (or it ought to).Without it any of your users that selected to use Gravatar will get a RoboHash avatar instead.
It wasn't happening in my case; the gravatar users were showing up with RoboHash images.It already checks to see if a Gravatar is present and serves it if found (or it ought to).
The user has chosen to use a Gravatar avatar. They have a Gravatar image on file. If I choose anything in the ACP other than RoboHash then their Gravatar image shows up. If I choose RoboHash then a RoboHash image shows up, not their Gravatar image.Make sure that your members have actually told XenForo to use their Gravatar. If they haven't chosen to display their Gravatar, then it'll default to RoboHash/Identicons.
View attachment 80102
Appending the robohash.org URL with the 'gravatar=hashed' option is all that's needed.For Gravatar enthusiasts, you can ask Robohash to use a Gravatar if one is available.
Put either the email, or the hashed version, in your image where the string normally goes -
For example: http://robohash.org/colin@robohash.org?gravatar=yes
or http://robohash.org/620050a4db5104bae758cd75171d64ca?gravatar=hashed
What we have here is... me not having uploaded the correct version from my dev machine. D: Anyway, I'll upload that, and maybe add in some more of RoboHash's options once I get a spare moment. My weekend is rather solid.Appending the robohash.org URL with the 'gravatar=hashed' option is all that's needed.
FYI: The way identicons work is that they're based on a hash of the user's email. Unregistered users (guests) have no email to hash so they always get the same thing. One possible solution might behowever, i noticed that all the guests that were allowed to post in the forum have similar avatars, is it possible to randomly generate identicon/avatars for each guests?
hi, awesome addon iversia,
however, i noticed that all the guests that were allowed to post in the forum have similar avatars, is it possible to randomly generate identicon/avatars for each guests?
thanks so much!
IF email !== null
THEN use hashed email
ELSE use hashed IP
<?php
class Iversia_Identicon_Listener
{
protected static $_helperCallbackAvatar;
public static function initDependencies(XenForo_Dependencies_Abstract $dependencies, array $data)
{
self::$_helperCallbackAvatar = XenForo_Template_Helper_Core::$helperCallbacks['avatar'];
if (self::$_helperCallbackAvatar[0] === 'self') {
self::$_helperCallbackAvatar[0] = 'XenForo_Template_Helper_Core';
}
XenForo_Template_Helper_Core::$helperCallbacks['avatar'] = array('Iversia_Identicon_Listener', 'getAvatarUrl');
}
public static function getAvatarUrl(array $user, $size, $forceType = '', $canonical = false)
{
if (!empty($user['avatar_date']))
{
return call_user_func(self::$_helperCallbackAvatar, $user, $size, $forceType, $canonical);
}
if (!empty($user['user_id']) && $forceType != 'default')
{
if ($user['gravatar'] && $forceType != 'custom')
{
return self::_getGravatarUrl($user, $size);
}
}
return self::_getDefaultAvatarUrl($user, $size);
}
protected static function _getDefaultAvatarUrl(array $user, $size)
{
$identicon = XenForo_Application::get('options')->IdenticonDefault;
return self::_getGravatarUrl($user, $size, $identicon);
}
protected static function _getGravatarUrl(array $user, $size, $default = '')
{
$identicon = XenForo_Application::get('options')->IdenticonDefault;
if ($user['user_id'] == null) {
$md5 = md5($user['unique_key']);
}
else if (empty($user['gravatar'])) {
$md5 = md5(strtolower(trim($user['email'])));
} else {
$md5 = md5(strtolower(trim($user['gravatar'])));
}
if ($default === '')
{
$default = '&d=' . urlencode($identicon);
}
else if (!empty($default))
{
$default = '&d=' . urlencode($default);
}
if (is_string($size))
{
$size = XenForo_Model_Avatar::getSizeFromCode($size);
}
if ($identicon == 'robohash' && empty($user['gravatar'])) {
return "https://robohash.org/{$md5}?size={$size}x{$size}&set=any";
} else {
return (XenForo_Application::$secure ? 'https://secure' : 'http://www')
. ".gravatar.com/avatar/{$md5}?s={$size}{$default}";
}
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.