I would like to show comments author google profile picture, if he entered a gmail.com email address, else I will show the gravatar in comments.
With my limitation in coding I managed to put sample code to construct further:
function comment_image() {
$email = get_avatar(get_comment_author_email());
$domains = array('gmail.com', 'google.com');
$pattern = "/^[a-z0-9._%+-]+@[a-z0-9.-]*(" . implode('|', $domains) . ")$/i";
if (preg_match($pattern, $email)) {
function email_to_userid() {
// get user id of the email address - xyz@gmail.com
//request google profile image url eg: https://www.googleapis.com/plus/v1/people/123456789?fields=image&key={API_KEY}
// above will retun URL: "url": "https://lh3.googleusercontent.com/-abcdef/bbbbbas/photo.jpg?sz=50"
// return the image URL
}
}
} elseif; {
echo get_avatar($comment, 60);
}
I will call the above function in my comments template to show the image:
<?php echo comments_image(); ?>
Thanks in advance for this great community.
If you problem is purely syntactical, this should help: