Made the avatar template tag an inclusion tag to be able to override the default template.

This commit is contained in:
Jannis Leidel 2012-08-21 14:36:49 +02:00
parent 59af1c3cb1
commit aa4e58168f
2 changed files with 7 additions and 3 deletions

View file

@ -0,0 +1 @@
<img src="{{ url }}" alt="{{ alt }}" width="{{ size }}" height="{{ size }}" />

View file

@ -34,7 +34,7 @@ def avatar_url(user, size=AVATAR_DEFAULT_SIZE):
@cache_result
@register.simple_tag
@register.inclusion_tag('avatar/avatar_tag.html')
def avatar(user, size=AVATAR_DEFAULT_SIZE):
if not isinstance(user, User):
try:
@ -47,8 +47,11 @@ def avatar(user, size=AVATAR_DEFAULT_SIZE):
else:
alt = unicode(user)
url = avatar_url(user, size)
return """<img src="%s" alt="%s" width="%s" height="%s" />""" % (url, alt,
size, size)
return {
'url': url,
'alt': alt,
'size': size,
}
@register.filter