Just trying to crate a simple comment form on a blog. I want to load the user’s gravatar (using jQuery) when he/she writes this in the email box.
How can I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The gravatar url looks like this:
Here are the rest of the options for the URL.
So all you’re going to have to do is include a function called md5 that returns the md5 hash of the user’s email. There are many online that do this, but I believe https://github.com/blueimp/JavaScript-MD5/blob/master/README.md works well. After that, just do:
I thought this was obvious, but I will add it for posterity’s sake:
If user emails are private and you’re showing this ala-stackoverflow in a listing, you are probably better off encoding the email on the server so that user emails are not publicly visible if you look at the source.