WordPress Gravatar Plugin
一个很好玩的能让评论的作者显示出自己在gravatar上设置的头像的插件,本文由Gravata官方网站摘录而来,偶懒得去翻译了,各位看的懂的就看哦,看不懂的就去找翻译的中文版本。偶向来都认为,学习外国先进的技术,最好就是要看原版的书,要不然经国人翻译过来了,国人的思想有时会或多或少加入了译文当中去,这样就变味了。所以呀,要想真正学好人家的技术,还是看原版的好!嘻嘻,偶的英文水平可不是盖的哟,羡慕不?HOHOHO
A plugin is available for WordPress 1.2 installations. The plugin makes available a tag called gravatar that, when used inside the Comment Loop, outputs the correct gravatar URL based on the commenters email address. It’s important to note that this plugin does not actually put a gravatar image by your comments, but makes it easier for you to edit that into your themes php files yourself.
Download wp_gravatar.zip
Installation: Download and extract the above file to your WordPress plugins directory, located at /wp-content/plugins</WORDPRESS fixed_bound="true">. Once the file is placed in the plugins directory, login to your WordPress installation, and click the “Plugins” tab on the main administration panel. Look through the list of installed plugins to find the one called “Gravatar”. Under the “Action” column for this plugin, click on “Activate”. Installation is now complete.
Usage: gravatar has the following syntax:
<?php gravatar({rating{, size{, default{, border}}}}) ?>
All of the parameters are optional. For example, the following will create a gravatar URL that allows all rating levels, is 80×80 pixels, uses no default image, and has no border:
<?php gravatar(); ?>
If you wish to restrict your gravatars to R rated and below, you’d do this:
<?php gravatar("R"); ?>
If you want the size of the image changed as well, supply the pixel dimension as the second argument (defaults to 80):
<?php gravatar("R", 40); ?>
If you want to use your own “Heat Vision and Jack” image as a default graphic (shows up when either no gravatar exists for a given user, or the given user’s gravatar exceeds the specified rating), you’d do this:
<?php gravatar("R", 40, "http://www.somewhere.com/heatvision.jpg"); ?>
You can also add a 1px border of any color you choose with the fourth parameter:
<?php gravatar("R", 40, "http://www.somewhere.com/heatvision.jpg", "FF0000"); ?>
If you wish to leave a parameter at its default while supplying other parameters, simply pass an empty string as the argument.
Remember that this only generates the URL, so you have to place the gravatar tag inside the src attribute of an img tag like so:
最新评论