I basically retrieve a user's gravatar image and uses that for their profiles on my site. If a user doesn't have a gravatar account or email is not assigned to their gravatar account a default image is shown instead from gravatar.
My question is, if for example gravatars website went down and I could not retrieve the user's gravatar image, is there anyway in php I can check to see if gravatar is returning an image and if not display a some text or something?
Obviously I can do a simple if statement; but checking in PHP if gravatar is returning an image is what I am not sure on.
If I cannot check if a image is being returned from Gravatar, checking if the link is online (accessible) would be fine I guess.
UPDATE:
I forgot to mention this is how i retrieve the image from gravatar:
function get_gravatar($email, $s = 50, $r = 'pg')
{
$defaultimage='mm';
$url='http://www.gravatar.com/avatar/';
$url.=md5(strtolower(trim($email)));
$url.="?s=$s&d=$defaultimage&r=$r";
return $url;
}
Then to display I do:
<a href="http://www.gravatar.com" target="_blank">
<img class="profileimgright profileimgframe" alt="Profile Image" src="<?php echo get_gravatar($_SESSION['email'], 180, 'pg') ?>" />
</a>
Status
header, and/or check the returnedContent-Type
header is of typeimage/*
. I would obviously use CURL as well