views:

70

answers:

2

I have implemented gravatar for a portal I am building and wanted to know if there is a default image URL for gravatar? Not all people who visit the site are logged in or have email addresses, in such a case, is there a default image that can be shown (accessible via gravatar url)

+2  A: 

Not really, no. That is missing the point of the Gravatar service. It is designed so that your users can register their email address(es) and associate a gravatar image with it/them. Your site (and other sites) can then query Gravatar to give back the image which is associated with the email address in question.

If you want an image showing for users who do not even enter an email address on your website, you have two solutions that I can see:

  1. Do it in your own code. When you are dealing with a user who has no email address, you can just output a default image of your own choosing. Of course, this means it will not be done using a gravatar address and it'll be something you'll need to be serving yourself.
  2. Register an email address yourself dedicated to users who do not have/enter their own. For example, you could register something like [email protected] and then register this with the Gravatar service and associate your chosen default image with this. Your own app code will still need to output the appropriate gravatar URL substituting this email address in place of the user's non-existant one when constructing the image URL, but it will allow you to use a gravatar URL which is something you have asked for.
Splash
+4  A: 

http://en.gravatar.com/site/implement/url

Step 5: just add a 'd' parameter to the url:

http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?d=identicon

EDIT:

And it also works without a hash:

http://www.gravatar.com/avatar/?d=identicon

EDIT2:

And also without anything:

http://www.gravatar.com/avatar
Macmade
Splash
See the edit. No need for a hash...
Macmade
Hmm, strange. According to the Gravatar instructions you linked to, the hash is required (not optional). I wonder if it working is by design or coincidence. However if it works, its certainly another option. :)
Splash
http://www.gravatar.com/avatar/default?d=identicon also works!!
Ritesh M Nayak
lol... And I just realized it also work without anything... : )
Macmade