diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -749,7 +749,13 @@ HasRepoPermissionAny, HasRepoPermissionA #============================================================================== def gravatar_url(email_address, size=30): - from pylons import url ## doh, we need to re-import url to mock it later + from pylons import url # doh, we need to re-import url to mock it later + + if (not str2bool(config['app_conf'].get('use_gravatar')) or + not email_address or email_address == 'anonymous@rhodecode.org'): + f = lambda a, l: min(l, key=lambda x: abs(x - a)) + return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30])) + if(str2bool(config['app_conf'].get('use_gravatar')) and config['app_conf'].get('alternative_gravatar_url')): tmpl = config['app_conf'].get('alternative_gravatar_url', '') @@ -761,11 +767,6 @@ def gravatar_url(email_address, size=30) .replace('{size}', str(size)) return tmpl - if (not str2bool(config['app_conf'].get('use_gravatar')) or - not email_address or email_address == 'anonymous@rhodecode.org'): - f = lambda a, l: min(l, key=lambda x: abs(x - a)) - return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30])) - ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme') default = 'identicon' baseurl_nossl = "http://www.gravatar.com/avatar/"