Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from emilsundberg/master
Browse files Browse the repository at this point in the history
Added exists() method to check if a specific email address has a gravata...
  • Loading branch information
thomaswelton committed Mar 26, 2014
2 parents c8dccd7 + 8084c37 commit 30af9c0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Thomaswelton/LaravelGravatar/Gravatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ public function image($email, $alt = null, $attributes = array(), $rating = null

return HTML::image($src, $alt, $attributes);
}

public function exists($email)
{
$this->setDefaultImage('404');

$url = $this->buildGravatarURL($email);
$headers = get_headers($url, 1);

return strpos($headers[0], '200') ? true : false;
}
}

0 comments on commit 30af9c0

Please sign in to comment.