內容簡介
這個外掛允許用戶透過「您的個人資料」頁面將個人照片與帳戶相關聯。管理員可以透過訪問「編輯使用者」頁面為用戶添加個人照片。上傳的圖像會被調整大小以符合在選項頁面上指定的維度;同時也會生成相應的縮略圖像。用戶的照片可以顯示在發佈或評論中,以幫助識別作者。新引入的模板標籤如下:
- userphoto_the_author_photo()
- userphoto_the_author_thumbnail()
- userphoto_comment_author_photo()
- userphoto_comment_author_thumbnail()
請注意:所有這些「模板標籤」必須出現在 PHP 腳本塊內(請參考以下示例)。前兩個應該在帖子循環中的the_author()附近放置,後兩個應該在評論循環中的comment_author()附近放置(或其各自相應的位置)。此外,如果設置了$authordata,就可以隨時調用userphoto_the_author_photo()和userphoto_the_author_thumbnail()(例如在側欄中)。這些模板標籤的輸出可以通過傳遞四個參數:$before、$after、$attributes和$default_src進行修改,方式如下:userphoto_the_author_photo($before, $after, $attributes, $default_src)。如果存在用戶照片(或提供了$default_src),則$before和$after參數中提供的文本將分別作為生成的img標籤的前綴和後綴(這是 WordPress 中的常見模式)。如果在$attributes參數中提供了屬性,則它們將作為生成的img元素的屬性返回。例如:userphoto_the_author_photo('', '', array(style => 'border:0'))。在0.8.1版本中新增了以下兩個模板標籤:
- userphoto($user, $before = '', $after = '', $attributes = array(), $default_src = '')
- userphoto_thumbnail($user, $before = '', $after = '', $attributes = array(), $default_src = '')
使用它們時,不需要設置全局$authordata即可顯示照片。只需傳遞$authordata、$curauth或其他包含用戶對象的變數,或(從0.9版開始)傳遞用戶ID或用戶登錄名即可。下面是一個示例,顯示如何將用戶的照片插入到發佈循環中:
//若他們沒有個人照片,這將顯示用戶的頭像。
while (have_posts()) : the_post();
外掛標籤
開發者團隊
原文外掛簡介
Allows a user to associate a profile photo with their account through their “Your Profile” page. Admins may
add a user profile photo by accessing the “Edit User” page. Uploaded images are resized to fit the dimensions specified
on the options page; a thumbnail image correspondingly is also generated.
User photos may be displayed within a post or a comment to
help identify the author. New template tags introduced are:
userphoto_the_author_photo()
userphoto_the_author_thumbnail()
userphoto_comment_author_photo()
userphoto_comment_author_thumbnail()
Important: all of these “template tags” must appear inside of PHP script blocks (see examples below).
The first two should be placed in the posts loop near the_author(), and the second two in the comments
loop near comment_author() (or their respective equivalents). Furthermore, userphoto_the_author_photo()
and userphoto_the_author_thumbnail() may be called anywhere (i.e. sidebar) if $authordata is set.
The output of these template tags may be modified by passing four parameters: $before, $after, $attributes, and $default_src,
as in: userphoto_the_author_photo($before, $after, $attributes, $default_src).
If the user photo exists (or $default_src is supplied), then the text provided in the $before and $after parameters is respectively
prefixed and suffixed to the generated img tag (a common pattern in WordPress). If attributes are provided in the $attributes
parameter, then they are returned as attributes of the generated img element. For example: userphoto_the_author_photo('', '', array(style => 'border:0'))
Just added in 0.8.1 release are these two new template tags:
userphoto($user, $before = '', $after = '', $attributes = array(), $default_src = '')
userphoto_thumbnail($user, $before = '', $after = '', $attributes = array(), $default_src = '')
By using these, it is uneccessary to set the global $authordata to display a photo. Just pass $authordata, $curauth or
whatever variable you have which contains the user object, or (as of version 0.9), pass in a user ID or a user login name.
Here’s an example that shows a few ways of inserting a user’s photo into the post loop:
//this will display the user’s avatar if they don’t have a user photo,
If you want to display the user’s photo in the sidebar, just get the user ID or object and pass it into userphoto() or userphoto_thumbnail() like this:
post_author); ?>
If you want to display a user’s photo their author page, you may do this:
get_queried_object()) ?>
In version 0.9 the boolean function userphoto_exists($user) has been introduced which returns true if the user has a photo and false if they do not.
Argument $user may be user object, ID, or login name. This function can be used along with avatars:
ID, 96);
?>
Or if the new “Serve Avatar as Fallback” option is turned on, then the avatar will be served by any of the regular calls to display the user photo:
Additionally, all of the regular function calls to display the user photo may be done away with alltogether if the new “Override Avatar with User Photo”
option is enabled:
user_email);
?>
Both options “Serve Avatar as Fallback” and “Override Avatar with User Photo” require that the ‘Avatar Display’ setting under Discussion be set to “Show”.
Uploaded images may be moderated by administrators via the “Edit User” page.
Localizations included for Spanish, German, Dutch, Polish, Russian, French, Hungarian, Brazilian Portuguese, Italian, and Catalan.
If you value this plugin, please donate to ensure that it may continue to be maintained and improved.
