How to get gravatar image from email using Jquery?

By Hardik Savani | October 28, 2016 | Category : Javascript Bootstrap HTML jQuery

Sometimes, we require to get gravatar image from email address in jquery. So, today i am going to share with you how to get gravatar image from email.

Gravatar is a service for providing globally unique avatars. We can simply create our account and set avatar image that we want. There are several developer and users are using this service. So, that way any of site we can simply get avatar image from email address from Gravatar account.

Today, in this example i also checked everything, If email does not registered then we can Set default image if user doesn't have Gravatar. So let's follow bellow example.

In this example i include following js and css.




Ok, so you can also simple follow bellow full email Or also you can check demo.


<!DOCTYPE html>



<title>Get gravatar image from email Jquery</title>

<link rel="stylesheet" href="">

<script type="text/javascript" src=""></script>

<script type="text/javascript" src=""></script>

<style type="text/css">


width: 100px;





<div class="container">

<h2>Get gravatar image from email jquery</h2>


<div class="form-group">


<input type="email" name="email" class="form-control email" required>


<div class="form-group">

<img src="" class="img" >


<div class="form-group">

<button class="btn btn-success set-gravtar">Get Gravatar!</button>




<script type="text/javascript">



var email = $(".email").val();

if(email != ''){

var md5 = $.md5(email);

var imgUrl = ''+md5+'?&d=404';













alert('Please enter email.');






I hope it can help you...

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: