Hello right know I have a small web application using Sails.JS and I'm trying to set a default image if the user doesn't have a gravatar account/profile.
This is the code that I use to hash the email in my controller:
var crypto = require('crypto');
req.session.email = 'user_email@gmail.com';
req.session.gravatar_hash = crypto.createHash('md5').update(req.session.email).digest('hex');
As you see I have in session the hash now.
So in my view I have:
<div class="gravatar" style="background-image: url('http://www.gravatar.com/avatar/<%=req.session.gravatar_hash%>?s=50');"></div>
This code works great for showing the gravatar (default or custom) image, but what If i want to do a validation so if the user doesn't have a gravatar I can use a custom image?? There is a way to validate that?