不用插件,怎样为博客建立Gravatars

原文在此

Gravatar是啥?

一个avatar是与用户交流的小图片,在很多论坛上都有,在博客上也越来越流行。 Gravatar是一个服务商,口号是“Globally Recognized Avatars“。你可以去注册一个玩玩,之后几乎不会再去访问它的网站。

注册了之后,每当你填入你的email地址,你的头像就会出现啦,当然这需要博主加上几行简单的代码。

What are the Benefits?

Draw attention to yourself. Most people comment on a website hoping for a little bit of traffic, so it makes sense that using any means within your arm’s reach is beneficial to you. A minute long process of signing up for a service and you get that attention.

People have been known to include scantily clad women, which certainly warrant a few clicks from weary lurkers in the depths of your archives. In short, a Gravatar can do a few things for you:

In the end, you spend two minutes or so signing up and uploading a picture, and you will see the results soon after.

我们捡重点的说:

HOW TO

打开comments.php然后看下面的步骤

1 为了需要生成头像,你需要发送点儿东东

<?
$email = $comment->comment_author_email;
$default = “”; // link to your default avatar
$size = 40; // size in pixels squared
$grav_url = “http://www.gravatar.com/avatar.php?gravatar_id=
” . md5($email) . “&default=” . urlencode($default) . “&size=” . $size;
?>

There isn’t much in there to understand. Set the $email variable to whatever works with your system. The one in place works with WordPress. After that, upload an image you want to serve when the user doesn’t have a Gravatar, input a size and you’re good to go.

 2 在出现头像的地方加入

<img src=”<?=$grav_url ?>” height=”<?=$size ?>” width=”<?=$size ?>” alt=”User Gravatar” />

这样就搞定鸟~

看完文章何不多讲几句订阅本站RSS :蘑菇日后更新,会及时送至您的RSS阅读器!

Comments

最简单的办法就是升级到2.5。哈哈

发表评论

(必填)

(必填)