mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Move alt attribute to kwargs.
This commit is contained in:
parent
c1f7abd2e4
commit
51375039df
3 changed files with 6 additions and 5 deletions
|
|
@ -1 +1 @@
|
|||
<img src="{{ url }}" alt="{{ alt }}" width="{{ size }}" height="{{ size }}" {% for key, value in kwargs.items %}{{key}}="{{value}}" {% endfor %}/>
|
||||
<img src="{{ url }}" width="{{ size }}" height="{{ size }}" {% for key, value in kwargs.items %}{{key}}="{{value}}" {% endfor %}/>
|
||||
|
|
@ -42,10 +42,11 @@ def avatar(user, size=settings.AVATAR_DEFAULT_SIZE, **kwargs):
|
|||
else:
|
||||
alt = six.text_type(user)
|
||||
url = avatar_url(user, size)
|
||||
kwargs.update({'alt': alt})
|
||||
|
||||
context = {
|
||||
'user': user,
|
||||
'url': url,
|
||||
'alt': alt,
|
||||
'size': size,
|
||||
'kwargs': kwargs,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ class AvatarTests(TestCase):
|
|||
result = avatar_tags.avatar(self.user.username)
|
||||
|
||||
self.assertIn('<img src="{}"'.format(avatar.avatar_url(80)), result)
|
||||
self.assertIn('alt="test" width="80" height="80" />', result)
|
||||
self.assertIn('width="80" height="80" alt="test" />', result)
|
||||
|
||||
def test_avatar_tag_works_with_user(self):
|
||||
upload_helper(self, "test.png")
|
||||
|
|
@ -199,7 +199,7 @@ class AvatarTests(TestCase):
|
|||
result = avatar_tags.avatar(self.user)
|
||||
|
||||
self.assertIn('<img src="{}"'.format(avatar.avatar_url(80)), result)
|
||||
self.assertIn('alt="test" width="80" height="80" />', result)
|
||||
self.assertIn('width="80" height="80" alt="test" />', result)
|
||||
|
||||
def test_avatar_tag_works_with_custom_size(self):
|
||||
upload_helper(self, "test.png")
|
||||
|
|
@ -208,7 +208,7 @@ class AvatarTests(TestCase):
|
|||
result = avatar_tags.avatar(self.user, 100)
|
||||
|
||||
self.assertIn('<img src="{}"'.format(avatar.avatar_url(100)), result)
|
||||
self.assertIn('alt="test" width="100" height="100" />', result)
|
||||
self.assertIn('width="100" height="100" alt="test" />', result)
|
||||
|
||||
def test_avatar_tag_works_with_kwargs(self):
|
||||
upload_helper(self, "test.png")
|
||||
|
|
|
|||
Loading…
Reference in a new issue