Search code examples
phpgravatar

Gravatar email hash function


Let's say my email is test@test.com, I am registered with Gravatar.com and I have defined a custom image.

Now, when I try and follow the instructions that appear on gravatar.com and do this:

$gravatar = md5( strtolower( trim( $user->email ) ) );

<img src="http://www.gravatar.com/avatar/<?= $gravatar ?>?s=100" />

I don't get the default gravatar image, so that means there's something wrong with the email address I entered.

But when I remove the strtolower and the trim functions, everything is working perfectly.

Note: $user->email = test@test.com (no trailing spaces or capitals anywhere).

Why is that? also, if I echo $gravatar with the strtolower and trim functions, it looks exactly the same.


Solution

  • Not sure what was the problem, it generates the same hash now. didn't before. Maybe I had a misspell somewhere, thanks anyways guys