站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
建站程序
开发
服务器
办公软件
开发教程
服务器教程
软件使用教程
运营教程
热门电子书
WordPress教程
宝塔面板教程
CSS教程
Shopify教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Using Gravatars
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
==What is a Gravatar?== == Gravatar是什么?== Gravatars are '''Globally Recognized Avatars'''. An avatar or gravatar is an icon, or representation, of a user in a shared virtual reality, such as a forum, chat, website, or any other form of online community in which the user(s) wish to have something to distinguish themselves from other users. Created by Tom Werner, gravatars make it possible for a person to have one avatar across the entire web. Avatars are usually an 80px by 80px image that the user will create themselves. Gravatars是'''全球公认的Avatars'''。一个avatar或者gravatar是一个图标或者图像,是用户在虚拟世界,如论坛,聊天,网页,或者其它形式的在线团体,想要将自己与其它用户区别开来的标记。Garatars 是由Tom Werner创建的,gravatars能使人们将一个avatar在整个网页上扩展。Avatars通常是一个80px 乘 80px的图像,用户可以自己创建。 [[WordPress:Image:gravatars-in-comments.png|frame|right|Gravatars in blog post comments]]A Gravatar is essentially the same thing, but they are all hosted on a single server and are called up by encrypting the users' email address via the MD5 algorithm. So instead of having one avatar on one forum you visit, and another at a blog you visit, you could have the same avatar at both. [[WordPress:Image:gravatars-in-comments.png|frame|right|博客文章评论中的Gravatars]]Gravatar本质上是同样的内容,但是是在一个单一的服务器上托管的,而且通过MD5算法,加密用户的电子邮件地址,调用的。因此不止将一个avatar放到你要访问的论坛上,将另一个avatar放到你要访问的博客上,你可以将同一个avatar放在这两个位置。 Gravatars can easily be used within WordPress with the Gravatar WordPress Plugin or added manually in the <tt>index.php</tt>, <tt>comments.php</tt> and <tt>comments-popup.php</tt> [[WordPress:Templates|template files]]. 拥有Gravatar WordPress插件,能够轻易地在WordPress内部使用Gravatars,或者动手将Gravatars添加到<tt>index.php</tt>, <tt>comments.php</tt>和 <tt>comments-popup.php</tt> [[WordPress:Templates|模板文件]]中。 ==How a Gravatar is Constructed== ==Gravatar是结构是怎样的== A Gravatar is a dynamic image resource that is requested from a server. The request URL is presented here, broken into its segments. The URL always begins with: Gravatar是动态的图像资源,可以从服务器中得到。需要的URL呈现在这里,分割成几段。URL通常开始是: <nowiki>http://www.gravatar.com/avatar.php?</nowiki> <nowiki>http://www.gravatar.com/avatar.php?</nowiki> A mandatory parameter named <tt>gravatar_id</tt> follows this. Its value is the hexadecimal MD5 hash of the requested users' email address with all whitespace trimmed. The value is case insensitive. 一个称为<tt>gravatar_id</tt>的命令参数遵循了这一点。数值是被请求的用户的电子邮件地址,但是去除了空格,十六进制的MD5 hash。参数值区分大小写。 gravatar_id=279aa12c3326f87c460aa4f31d18a065 gravatar_id=279aa12c3326f87c460aa4f31d18a065 An optional <tt>rating</tt> parameter may follow with a value of <tt>[ G | PG | R | X ]</tt> which determines the highest rating (inclusive) that will be returned. 可选择的<tt>rating</tt>参数后面可能有参数值<tt>[ G | PG | R | X ]</tt>,这个参数值决定了返回的最高级别(包含的)。 &rating=R &rating=R Gravatar offers a [http://gravatar.com/rating.php rate checking service] so you can determine your rate. Gravatar提供了[http://gravatar.com/rating.php rate checking 服务],因此你可以决定你的rate。 An optional <tt>size</tt> parameter may follow that specifies the desired width and height of the Gravatar. Valid values are from 1 to 80 inclusive. Any size other than 80 will cause the original Gravatar image to be downsampled using bicubic resampling before output. 可选择的<tt>大小</tt>参数可能会遵循规定的Gravatar的宽度和高度。有效的参数值包括1到80。除了80外的任何的大小会导致原始的Gravatar图像downsampled,使用bicubic resampling才能够产出。 &size=40 &size=40 An optional <tt>default</tt> parameter may follow that specifies the full [[WordPress:Glossary#URL|URL]], encoded URL, protocol included, of a GIF, JPEG, or PNG image that should be returned if either the requested email address has no associated gravatar, or that Gravatar has a rating higher than is allowed by the <tt>rating</tt> parameter. 可选择的<tt>默认</tt>参数可能遵循规定的完整的[[WordPress:Glossary#URL|URL]],编码的URL,包含的协议,如果被请求的电子邮件地址没有相关的gravatar或者Gravatar拥有的rating比<tt>rating</tt>参数中规定的要高,会返回GIF, JPEG, 或者 PNG 图像。 &default=http%3A%2F%2Fwww.somesite.com%2Fsomeimage.jpg &default=http%3A%2F%2Fwww.somesite.com%2Fsomeimage.jpg An optional <tt>border</tt> parameter may follow that specifies the hexadecimal value of a 1px border to be overlaid on the Gravatar. The supplied value may be either the full six character hex string (e.g. <tt>FF0000</tt> for red) or the abbreviated three character hex string (e.g. <tt>F00</tt> for red). 可选择的<tt>border</tt>参数可能遵循Gravatar覆盖的1px border的十六进制数值。提供的参数值可能是完整的六位字符的十六进制字符串(例如<tt>FF0000</tt>表示红色)或者简化的三个字符的十六进制字符串(例如<tt>F00</tt>表示红色)。 &border=FF0000 &border=FF0000 == Using Gravatars in WordPress == == 在WordPress中使用Gravatars == [[WordPress:Image:gravatarCWE.gif|frame|right|An example of a Gravatar]]For most people, encrypting an email address with MD5 is no easy task, most of the time requiring [http://www.php.net/ PHP] or other form of scripting. Several [[WordPress:Plugins|WordPress Plugins]] have been created to help with this task, such as the [http://www.gravatar.com/implement.php#section_2_2 Gravatar.com Plugin] and [http://zenpax.com/gravatars2/ Gravatars2 Enhanced Caching Plugin].For information on using and installing those WordPress Plugins, see the Plugin's documentation. [[WordPress:Image:gravatarCWE.gif|frame|right| Gravatar的一个例子]]对于大多数人而言,用MD5加密电子邮件并不是简单的任务,大多数时候,需要[http://www.php.net/ PHP]或者其它形式的脚本。已经创建了几个[[WordPress:Plugins|WordPress 插件]]帮助完成这个任务,例如[http://www.gravatar.com/implement.php#section_2_2 Gravatar.com 插件] 和 [http://zenpax.com/gravatars2/ Gravatars2 提升的隐藏插件]。关于安装和使用这些WordPress插件的信息,请看看插件文档。 As of WordPress 2.5, Gravatars are built-in and require no additional Plugins for basic usage and management. 从WordPress2.5版本开始,Gravatars是内置的而且不需要额外的插件,简单地使用和管理Gravatars。 WordPress 2.5 marries theme authors and casual WordPress users together with support for Gravatars in the WordPress Administration Panels. Theme authors have an option to include Gravatars in their designs, and are recommended to do so. WordPress users can easily control their Gravatar usage in the '''Settings > Discussion''' Administration Panel. WordPress2.5版本与主题作者,临时的WordPress用户,WordPress管理面板中的Gravatars支持相结合。主题作者拥有一个选项,将Gravatars包含在设计中,而且也得到建议,可以这样做。WordPress可以在'''设置 >讨论'''管理面板中轻易地控制Gravatar的用法。 WordPress users can change: WordPress的用户可以更改: * Whether Avatars (aka, Gravatars) are displayed or not. *是否显示Avatars (aka, Gravatars)。 * Which rating of Avatars are shown. *显示的Avatars是哪个rating。 === Theme Support for WordPress 2.5 === ===关于WordPress2.5的主题支持 === The function to add Gravatars to your theme is called: <code>get_avatar</code>. The function returns a complete image HTML tag of the Avatar. 将Gravatars添加到你的主题的函数,称为:<code>get_avatar</code>。这个函数返回了Avatar的HTML标签完整的图像。 The function is called as follows: 调用的函数是: <nowiki><?php echo get_avatar( $id_or_email, $size = '96', $default = '<path_to_url>' ); ?></nowiki> <nowiki><?php echo get_avatar( $id_or_email, $size = '96', $default = '<path_to_url>' ); ?></nowiki> The parameters are: 参数是: * id_or_email '''(required)''': Author’s User ID (an integer or string), an E-mail Address (a string) or the comment object from the comment loop. ''Note: with most comment templates you can use <code>$comment</code> here, in order to display the gravatar of the commenter. In other templates, you can use <code>get_the_author_id()</code> here''. * id_or_email '''(必需的)''':作者的用户ID(一个整数或者字符串),一个电子邮件地址(一个字符串)或者来自评论loop的评论object。''注: 拥有大多数评论模板,你可以在这里使用<code>$评论</code> ,以显示评论员的gravatar。在其它模板中,你可以在这里使用 <code>get_the_author_id()</code> ''。 * size '''(optional)''': Avatar display size (max is 512). * 大小 '''(可选择的)''':Avatar显示大小(最大是512)。 * default '''(optional)''': Absolute location of the default avatar to use (used when the person has no email address associated with them). If this is left blank then the gravatar you see [http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536 here] will be used as the default avatar. * 默认 '''(可选择的)''':使用的默认avatar的绝对路径(当人们没有与gravatar相关的电子邮件地址时,就会使用这个绝对路径)。如果这个路径是空白的,那么你看到的gravatar[http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536 here]会作为默认avatar来使用。 Some things to note here: 这里要注意的一些事项: * The default Avatar size is 96x96 if you do not set the size using the size paramater. *如果你没有使用大小参数设置大小,默认的Avatar大小是96x96。 * The default Avatar is Gravatar *默认Avatar是Gravatar * The Avatars will show only if the user allows them in the WP Admin Panel (enabled by default). *用户在WP管理面板中允许Avatars(默认是允许的)的时候,Avatar才会显示。 * The Avatars will only show based on the rating the user has selected in the WordPress Administration Panels. * Avatars会根据用户在WordPress管理面板上选择的rating显示。 Code output: 代码输出: The default output is when using the above function is listed below. Various classes are applied to img element to help you with element styling. 使用上述函数列在下面时,默认的输出。Img元素上应用了不同的classes,帮助你设计元素。 <pre> <img alt='' src='http://gravatarurl_or_default' class='avatar avatar-$size' height='$size' width='$size' /> </pre> <pre> <img alt='' src='http://gravatarurl_or_default' class='avatar avatar-$size' height='$size' width='$size' /> </pre> If the gravatar reverts to the default image due to a lack of an e-mail address (i.e. a pingback or trackback), whether you have specified a default or not, the <code>img</code> element will also be given a CSS class of <code>avatar-default</code>. 如果因为缺少电子邮件地址,gravatar返回到默认图像(例如pingback 或者trackback),不管你有没有规定默认设置,<code>img</code>也会得到code>avatar-default</code>的CSS class。 === Backwards Compatibility === === 向后兼容 === If you wish to develop a WordPress Theme with Avatars for 2.5 and below, add a check for the Gravatar function to the code: 如果你想使用Avatars2.5版本以及更低的版本,开发WordPress主题,向代码添加Gravatar函数: <nowiki>if (function_exists('get_avatar')) { echo get_avatar($email); } else { //alternate gravatar code for < 2.5 $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id= " . md5($email) . "&default=" . urlencode($default) . "&size=" . $size; echo "<img src='$grav_url'/>"; }</nowiki> <nowiki>if (function_exists('get_avatar')) { echo get_avatar($email); } else { //alternate gravatar code for < 2.5 $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id= " . md5($email) . "&default=" . urlencode($default) . "&size=" . $size; echo "<img src='$grav_url'/>"; }</nowiki> === Gravatar.com Plugin === === Gravatar.com插件 === The [http://www.gravatar.com/implement.php#section_2_2 Gravatar.com Plugin] from Gravatar is the official Plugin for handling Gravatars. 来自Gravatar的[http://www.gravatar.com/implement.php#section_2_2 Gravatar.com 插件]是处理Gravatar的官方插件。 To use it: 怎样使用这个插件: # Install and activate the Plugins. #安装并且激活插件。 #Place the <code><?php gravatar(); ?></code> function tag into the WordPress template file within the [[WordPress:The Loop|WordPress Loop]] within an HTML image tag: #将<code><?php gravatar(); ?></code>函数标签放入HTML图像标签内的[[WordPress:The Loop|WordPress Loop]]内的WordPress模板文件中: <img src="<?php gravatar(); ?>" alt="Gravatar" /> <img src="<?php gravatar(); ?>" alt="Gravatar" /> For more information on using and installing the Gravatars.com WordPress Plugin, visit the [http://www.gravatar.com/ Gravatars site]. 关于更多的使用和安装Gravatars.com WordPress插件的信息,请访问[http://www.gravatar.com/ Gravatars 站点]。 === Customizing Your Gravatars === === 自定义你的 Gravatars === There are several settings to customize the Gravatars. The setting parameters are: 有几种设置可以自定义Gravatars。设置参数是: <?php gravatar(''"rating", size, "default", "border"''); ?> <?php gravatar(''"rating", size, "default", "border"''); ?> ;rating :The highest rating of Gravatar to be shown. The values are <tt>G, PG, R,</tt> and <tt>X</tt>. Showing only Gravatar's with a rating higher than <tt>PG</tt> can be accomplished with the following code: ;rating:显示的Gravatar的最高的rating。参数值是<tt>G, PG, R,</tt> and <tt>X</tt>。只用高于<tt>PG</tt>的rating显示Gravatar's,可以通过下面的代码实现: <?php gravatar("PG"); ?> <?php gravatar("PG"); ?> ;size :Gravatar size is 80px by 80px by default. To change the sie, change the size value, keeping the size square, such as 80px by 80px: ;大小:Gravatar大小默认是80px 乘80px。更改大小,更改大小参数值,保存大小square,例如80px乘80px: <?php gravatar("PG", 80); ?> <?php gravatar("PG", 80); ?> ;default :If a user is not registered with Gravatars or another compatible Avatar service, a default image will be shown. You can override this with a custom image as a PNG, JPG, or GIF. ;默认:如果用户没有注册Gravatar或者其它兼容的Avatar服务,会显示默认图像。你可以用一个自定义的图像,如PNG, JPG, 或者GIF覆盖默认图像。 <?php gravatar("PG",40,"<nowiki>/images/no_gravatar.gif</nowiki>"); ?> <?php gravatar("PG",40,"<nowiki>/images/no_gravatar.gif</nowiki>"); ?> ;border :To add a border, use the <tt>border</tt> function. It will add a 1px wide border around the Gravatar of the color that you choose. By default there is no border. The following is an example of a Gravatar that will be no higher than a <tt>PG</tt> rating, be 40px by 40px, have a default image if no Gravatar is present, and have a 1px red border: ;边框:要添加边框,需要使用<tt>border</tt>函数,就会在Gravatar的周围,添加1px宽度的边框,边框颜色是你选择的颜色。默认情况下,没有边框。下面是Gravatar的一个例子,不高于<tt>PG</tt> rating,40px 乘 40px,如果没有呈现Gravatar,就会有一个默认图像,而且有一个1px的红色边框。 <?php gravatar("PG",40,"<nowiki>/images/no_gravatar.gif</nowiki>","FF0000"); ?> <?php gravatar("PG",40,"<nowiki>/images/no_gravatar.gif</nowiki>","FF0000"); ?> ==Resources== ==资源== * [http://www.gravatar.com/ Gravatar] * [[WordPress:Plugins|WordPress Plugins]] * [http://www.obeattie.com/2006/05/20/meet-the-gravatars/ oBeattie : Meet the Gravatars] * [http://www.gravatar.com/implement.php Gravatars Implement Page] * [http://txfx.net/code/wordpress/gravatar-signup/ Gravatar Signup Plugin] * [http://fecklessmind.com/main/7/live-comment-preview-now-with-live-gravatars Live Gravatar Preview Hack] * [http://weblogtoolscollection.com/archives/2008/03/03/gravatars-and-wordpress-25/ Gravatars & WordPress 2.5] * [http://www.themelab.com/2008/05/09/add-gravatar-support-to-your-wordpress-comments/ Add Gravatar Support to Your WordPress Comments] * [http://www.gravatar.com/ Gravatar] * [[WordPress:Plugins|WordPress 插件]] * [http://www.obeattie.com/2006/05/20/meet-the-gravatars/ oBeattie : 符合Gravatars] * [http://www.gravatar.com/implement.php Gravatars Implement Page] * [http://txfx.net/code/wordpress/gravatar-signup/ Gravatar Signup 插件] * [http://fecklessmind.com/main/7/live-comment-preview-now-with-live-gravatars Live Gravatar Preview Hack] * [http://weblogtoolscollection.com/archives/2008/03/03/gravatars-and-wordpress-25/ Gravatars & WordPress 2.5] * [http://www.themelab.com/2008/05/09/add-gravatar-support-to-your-wordpress-comments/ 给WordPress评论添加Gravatar支持]
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)