[damned-lies] Add a javascript fallback for invalid avatar url
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Add a javascript fallback for invalid avatar url
- Date: Sat, 26 Sep 2015 15:14:10 +0000 (UTC)
commit 5078ea1c633d9b1b70672880db41842b7c579e34
Author: Grégoire Détrez <gregoire detrez gu se>
Date: Sat Sep 26 15:50:29 2015 +0200
Add a javascript fallback for invalid avatar url
https://bugzilla.gnome.org/show_bug.cgi?id=671180
people/templatetags/people.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/people/templatetags/people.py b/people/templatetags/people.py
index 144335f..a981ea8 100644
--- a/people/templatetags/people.py
+++ b/people/templatetags/people.py
@@ -21,6 +21,7 @@ def people_list(lst):
@register.filter
def people_image(person):
+ nobody = settings.STATIC_URL + "img/nobody.png"
if person.use_gravatar:
digest = hashlib.md5(person.email.lower().encode("utf-8")).hexdigest()
tag = '<img src="https://secure.gravatar.com/avatar/%(hash)s.jpg?%(qs)s" alt="gravatar icon">' % {
@@ -29,7 +30,7 @@ def people_image(person):
'qs': urlencode({'s': '80', 'd': 'identicon', 'r': 'g'}),
}
elif person.image:
- tag = '<img src="%s" alt="%s">' % (person.image, person.name)
+ tag = '<img src="%s" alt="%s" onerror="this.onerror = null; this.src=\'%s\'">' % (person.image,
person.name, nobody)
else:
- tag = '<img src="%simg/nobody.png" alt="generic person icon">' % settings.STATIC_URL
+ tag = '<img src="%s" alt="generic person icon">' % nobody
return mark_safe(tag)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]