三月 21, 2006

[外掛] Gravatar 全球認證肖像

認證肖像 Gravatar (Globally recognized avatar),主要是提供顯示圖片的功能。只要到 Gravatar 的網站填寫註冊單,系統會寄確認信到你的信箱,從信裡附的網址再連回 Gravatar 網站即完成註冊手續。接下來你可以上傳一張 80 x 80 大小的圖片當成你專有的顯示圖片,不過此時你還不能馬上使用,因為圖片還必須評估等級 (G 普通級、PG 輔導級、R 和 X 為限制級),評估完成時系統會寄信通知你,這時你才能開始使用。

因為圖片是儲存在 Gravatar 的伺服器上,所以取用是透過一個獨一無二的網址,如下 (網址後面可能還有其它參數,詳細說明請見 Gravatar 的 How the URL is constructed):

http://www.gravatar.com/avatar.php?gravatar_id=<MD5 hash code>

<MD5 hash code> 是你的 e-mail 經過 MD5 checksum 計算之後,所得到的結果。MD5 是一種單向的雜湊演算法,一般人不太可能能從結果往回推算出你的 e-mail,可以適度的保護你的 e-mail,避免你的 e-mail 被 SPAM 拿到,進而被 SPAM 塞爆信箱。

Gravatar 如何應用在我們的 blog 上呢?想當然爾就是透過大家留下迴響時輸入的 e-mail,到 Gravatar 查詢這個 e-mail 是否有對應的顯示圖片,如果有就顯示在該迴響的旁邊,如果沒有則可以顯示一個預設的圖片,整個過程都是由系統來執行,你不必去輸入 (也可以不用去記憶) 屬於你的那一串 Gravatar 網址。

可以看範例 http://www.tiec.tp.edu.tw/lifetype/post/102/545

大家可以不用擔心你在 blog 輸入的 e-mail 會被外流。除了 blog 的管理者 (也就是我) 之外,別人看不到你輸入的 e-mail。另外,向 Gravatar 查詢時也會經過 MD5 雜湊處理,所以也是不用擔心的。


本文部份引用文章 http://sanwangx.brain-c.com/archives/2005_01/17_161/

Shih-Hsien’s BLOG » Blog Archive » Gravatar 讓你的 blog 留言也有大頭貼



LifeType 外掛中的說明檔:

Plugin: Gravatar
Author: Original by Dani Armengol, Modified by Mark Wu
Release Date: 2005/01/23
Version: 1.0

Returns the URL of an (gr)avatar for every comment. The image is loaded from Gravatar.com

In order to use, simply include the following:
1. $gravatar->isEnabled() to check the plugin is enabled or not.
2. $gravatar->gravatar($comment,$rating,$default,$size) to get to Avatar from Gravatar.com

Where:
1. $rating is the allowed rating of avatar. Default is "G"
2. $default is the URL of the default image that will be shown in case there is no gravatar available or if the user did not give an email address. You also can choose your default avatar from configuration panel. Default is "default.jpg"
3. $size is the desired size in pixels of the gravatar. Default is 40.

Example:
Add the following code to postandcomments.template:
{if $gravatar->isEnabled()}
<img src="{$gravatar->gravatar($comment)}" width="{$gravatar->getSize()}" height="{$gravatar->getSize()}" align="left" />
{/if}

You can add your own default avatar image to /plugin/gravatar/avatars. This plugin only support GIF and JPG format currently.

如果你的部落格迴響也想要有全球認証肖像。

1. 請先在個人網誌設定中啟用「全球認證肖像圖示」。

2. (這個步驟,可以先不用做,如果沒有顯示再自行加入程式)請使用模版編輯器!在 (postandcomments.template 中對應位置加入下面的紅色程式碼:

<a name="{$comment->getId()}"></a>

<!-- 全球認証肖像 -->
{if $gravatar->isEnabled()}
<img src="{$gravatar->gravatar($comment)}" width="{$gravatar->getSize()}" height="{$gravatar->getSize()}" align="right" />
{/if}
<!-- end 全球認証肖像 -->

<div class="comments-body">
{$comment->getText()}
</div>

3. 記得在迴響時一定要輸入e-mail 才會顯示肖像圖示!


發佈者: 陳怡杰 老師 at 23:43│  點閱次數 (1160)│ 修改文章管理迴響迴響 (1)部落格學習筆記
回應文章

1

終於成功了 !

Posted by 林杏玫 at 06/04/2006, 09:05
(必要)
authimage