Skip to content

Commit

Permalink
Don't expose user names through alt tags, solves #189, solves #188, r…
Browse files Browse the repository at this point in the history
…elates to #181
  • Loading branch information
johanneswilm committed Aug 10, 2022
1 parent 3e12122 commit 7d276ea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions avatar/templatetags/avatar_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ def avatar(user, size=settings.AVATAR_DEFAULT_SIZE, **kwargs):
if not isinstance(user, get_user_model()):
try:
user = get_user(user)
alt = str(user)
if settings.AVATAR_EXPOSE_USERNAMES:
alt = str(user)
else:
alt = _("User Avatar")
url = avatar_url(user, size)
except get_user_model().DoesNotExist:
url = get_default_avatar_url()
alt = _("Default Avatar")
else:
alt = str(user)
if settings.AVATAR_EXPOSE_USERNAMES:
alt = str(user)
else:
alt = _("User Avatar")
url = avatar_url(user, size)
kwargs.update({"alt": alt})

Expand Down

0 comments on commit 7d276ea

Please sign in to comment.