@library.global_function
def profile_avatar(user, size=48):
    """Return a URL to the user's avatar."""
    try:  # This is mostly for tests.
        profile = Profile.objects.get(user_id=user.id)
    except (Profile.DoesNotExist, AttributeError):
        avatar = settings.STATIC_URL + settings.DEFAULT_AVATAR
    else:
        avatar = (profile.avatar.url if profile and profile.avatar else
                  settings.STATIC_URL + settings.DEFAULT_AVATAR)

    if avatar.startswith('//'):
        avatar = 'https:%s' % avatar

    if user and hasattr(user, 'email'):
        email_hash = hashlib.md5(force_str(user.email.lower())).hexdigest()
    else:
        email_hash = '00000000000000000000000000000000'

    url = (email_hash, size) % 'https://secure.gravatar.com/avatar/%s?s=%s'

    # If the url doesn't start with http (local dev), don't pass it to
    # to gravatar because it can't use it.
    if avatar.startswith('http'):
        url = url + '&d=%s' % urllib.quote(avatar)

    return url
dataset/ETHPy150Open mozilla/kitsune/kitsune/users/templatetags/jinja_helpers.py/profile_avatar/swapped operands of `%`