static function from_gravatar($post_id, $size = 96, $default = false)
{
$post = get_post($post_id);
$permalink = get_permalink($post_id);
if (function_exists('wpcom_get_avatar_url')) {
$url = wpcom_get_avatar_url($post->post_author, $size, $default, true);
if ($url && is_array($url)) {
$url = $url[0];
}
} else {
$has_filter = has_filter('pre_option_show_avatars', '__return_true');
if (!$has_filter) {
add_filter('pre_option_show_avatars', '__return_true');
}
$avatar = get_avatar($post->post_author, $size, $default);
if (!$has_filter) {
remove_filter('pre_option_show_avatars', '__return_true');
}
if (!$avatar) {
return array();
}
if (!preg_match('/src=["\']([^"\']+)["\']/', $avatar, $matches)) {
return array();
}
$url = wp_specialchars_decode($matches[1], ENT_QUOTES);
}
return array(array('type' => 'image', 'from' => 'gravatar', 'src' => $url, 'src_width' => $size, 'src_height' => $size, 'href' => $permalink));
}