Commits

David Chambers  committed e35780d

Changed `gravatar` template filter to make Gravatar settings optional once again.

  • Participants
  • Parent commits 87f83c7

Comments (0)

Files changed (1)

File templatetags/mango_extras.py

 @register.filter
 @stringfilter
 def gravatar(email_hash):
+    pairs = []
+    if GRAVATAR_IMAGE_SIZE:
+        pairs.append(('s', GRAVATAR_IMAGE_SIZE))
+    if GRAVATAR_DEFAULT_IMAGE_URL:
+        pairs.append(('d', GRAVATAR_DEFAULT_IMAGE_URL))
     # Passing a tuple of tuples produces a canonical URL, avoiding unnecessary
     # HTTP requests which could result if a dictionary were passed instead.
-    qs = urllib.urlencode((('s', GRAVATAR_IMAGE_SIZE), ('d', GRAVATAR_DEFAULT_IMAGE_URL)))
-    return 'http://www.gravatar.com/avatar/%s?%s' % (email_hash, qs)
+    return 'http://www.gravatar.com/avatar/%s?%s' % (email_hash, urllib.urlencode(pairs))
 
 @register.filter
 def isoformat(timestamp):