mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-05-04 21:54:49 +00:00
Made the avatar template tag an inclusion tag to be able to override the default template.
This commit is contained in:
parent
59af1c3cb1
commit
aa4e58168f
2 changed files with 7 additions and 3 deletions
1
avatar/templates/avatar/avatar_tag.html
Normal file
1
avatar/templates/avatar/avatar_tag.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<img src="{{ url }}" alt="{{ alt }}" width="{{ size }}" height="{{ size }}" />
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue