bvmyeha88 / django-gravatar

Automatically exported from code.google.com/p/django-gravatar
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Query string separator ('?') missing from gravatar URL construction #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, the gravatar URL that gets the image for a user is constructed
as follows:

/gravatar/templatetags/gravatar.py:
def gravatar_for_email(email, size=80):
    url = "%savatar/%s/" % (GRAVATAR_URL_PREFIX,
hashlib.md5(email).hexdigest())
    url += urllib.urlencode({"s": str(size)})
    return escape(url)

The problem is that it returns a url that's missing the query string separator:

http://www.gravatar.com/avatar/.../s=80

The result is that the s attribute is ignored, and the size 80 is always
return no matter what s is set to.

A simple fix is to add the "?" before the query string is appended to the url.

def gravatar_for_email(email, size=80):
    url = "%savatar/%s/" % (GRAVATAR_URL_PREFIX,
hashlib.md5(email).hexdigest())
    url += "?" + urllib.urlencode({"s": str(size)})
    return escape(url)

This works as expected, and the image returned now responds to the s attribute.

Original issue reported on code.google.com by jim.ere....@gmail.com on 10 Sep 2008 at 6:02

GoogleCodeExporter commented 9 years ago
He's right. Please fix this, thank you!! :)

Original comment by antonio....@gmail.com on 9 Dec 2008 at 12:27