[WordPress] 外掛分享: Post Avatar

WordPress 外掛 Post Avatar 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Post Avatar」是 2007-05-24 上架。
  • 目前有 200 個安裝啟用數。
  • 上一次更新是 2018-08-23,距離現在已有 2446 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.9 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6.3 以上。
  • 有 1 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

garinungkadol |

外掛標籤

post | image | images | avatars | thumbnail |

內容簡介

允許作者在文章編輯畫面中從預定義的圖片列表中選擇圖片。這張圖片將與文章一起顯示。

Post Avatar 的概念類似於 LiveJournal userpic,作者可以選擇網站所有者上傳的圖像。由 Dominik Menke 開發。

特點

在文章編輯畫面中輕鬆選擇圖片。
掃描圖片選項文件夾子目錄中的圖片。
允許使用以下檔案類型:.jpg、.jpeg、.gif 和 .png。
靈活地自訂頭像顯示。

使用默認的 HTML/CSS 標記顯示頭像。
可以在“設置”畫面中編輯 HTML/CSS 標記。
使用主題中的模板標記和自定義過濾器進行進階自訂。

白俄羅斯語、捷克語、荷蘭語、法語、德語、印地語、愛爾蘭語、意大利語、波蘭語、羅馬尼亞語、塞爾維亞語克羅埃西亞語、西班牙語的國際語言支援
不顯示缺少的圖片。
可以進一步擴展以顯示頁面和自定義文章類型的圖片。

提交錯誤和論壇支援

WordPress 論壇

Post Avatar 主頁

請投票和評論

非常感謝您的投票和反饋。

進階自訂
前端顯示

預設情況下,外掛使用以下過濾器: the_content() 和 the_excerpt()。

使用過濾鉤 OVERRIDE HTML DISPLAY: gklpa_the_postavatar

gklpa_the_postavatar 鉤子接受兩個參數:

$post_avatar_text - 原始 HTML 顯示。

$post_avatar - 帖子頭像數據,以數組格式提供。其密鑰為:

avatar_url:圖像的 URL
show_image_dim:如果為 1,則顯示圖像尺寸;如果為 0,則隱藏圖像尺寸
image_height:圖像高度的整數值或如果關閉圖像尺寸,則為 null
image_width:圖像寬度的整數值或如果關閉圖像尺寸,則為 null
post_id:當前帖子 ID
post_title:圖像屬性的帖子標題
image_name:圖像文件名

示例:如果未選擇頭像,則顯示預設圖像

此示例使用由站點管理員定義的 HTML/CSS 設置。

add_filter( 'gklpa_the_postavatar', 'prefix_show_default_image', 10, 2 );
function prefix_show_default_image( $post_avatar_html, $post_avatar_array ){
global $post, $gklpa_plugin_settings;

// 顯示預設圖像;
if( is_null( $post_avatar_array ) ){
if( !empty( $gklpa_plugin_settings['css_class'] ) {
$css = 'class="' . $gkl_plugin_settings['css_class']. '"';
}
$post_avatar_html = $gklpa_plugin_settings['html_before' ] . '' . esc_attr(strip_tags($post->post_title) ) . ''. $gklpa_plugin_settings['html_after'];
}
return $post_avatar_html;
}

使用自定義內容鉤覆蓋 HTML 顯示

如果您想要完全更改 HTML 或覆蓋它,則可以使用自定義內容鉤。

原文外掛簡介

Allow authors to select an image from a pre-defined list while in the Post Editor screen. This image will be displayed together with a post.
Post Avatar is similar in concept to Livejournal userpics wherein authors choose images uploaded by the site owner. Developed with Dominik Menke.
Features

Easy selection of images from within the Post Editor screen.
Scans images in sub-directories of the image option folder.
Allows the following file types: .jpg, .jpeg, .gif and .png.
Flexible with customizing avatar display.

Display avatars using the default HTML/CSS tags.
HTML/CSS tags can be edited from with the Settings screen.
Use template tags and custom filters within themes for advanced customization.

International language support for Belorussian, Czech, Dutch, French, German, Hindi, Irish, Italian, Polish, Romanian, Serbo-Croatian, Spanish
Does not display missing images.
Can be further extended to show images for pages and custom post types

Bug Submission and Forum Support
WordPress Forum
Post Avatar home page
Please Vote and Review
Your votes and feedback are greatly appreciated. Thanks.
Advanced Customization
For Front End Display
By default, the plugin hooks into the following filters: the_content() and the_excerpt().
OVERRIDE HTML DISPLAY USING FILTER HOOK: gklpa_the_postavatar
The gklpa_the_postavatar filter takes two parameters:

$post_avatar_text – Original HTML display

$post_avatar – Post Avatar data in array format. The keys are:
avatar_url: The URL to the image
show_image_dim: 1 indicates to show image dimensions, 0 to hide them
image_height: integer value of image height or null if image dimensions is turned off
image_width: integer value of image width or null if image dimensions is turned off
post_id: ID of current post
post_title: Post title for the image attribute
image_name: Image file name

Example: Display a default image if no avatar is selected
This example makes use of the HTML/CSS settings defined by the site admin.
add_filter( 'gklpa_the_postavatar', 'prefix_show_default_image', 10, 2 );
function prefix_show_default_image( $post_avatar_html, $post_avatar_array ){
global $post, $gklpa_plugin_settings;

// Display default image;
if( is_null( $post_avatar_array ) ){
if( !empty( $gklpa_plugin_settings['css_class'] ) {
$css = 'class="' . $gkl_plugin_settings['css_class']. '"';
}
$post_avatar_html = $gklpa_plugin_settings['html_before' ] . '' . esc_attr(strip_tags($post->post_title) ) . ''. $gklpa_plugin_settings['html_after'];
}
return $post_avatar_html;
}

OVERRIDE HTML DISPLAY WITH CUSTOM CONTENT HOOK
If you want to change the HTML completely or override the option to display avatars automatically, use the remove_filter() like so:
remove_filter(‘the_content’, ‘gkl_postavatar_filter’, 99 );
remove_filter(‘the_excerpt’, ‘gkl_postavatar_filter’, 99 );
You can then define your own the_content filter function that makes use of the gkl_postavatar() or gkl_get_postavatar() functions
You will need to use the function gkl_get_postavatar() which takes the post object and returns the array of post avatar information.

$post_avatar_array – Post Avatar data in array format. The keys are:
avatar_url: The URL to the image

show_image_dim: 1 indicates to show image dimensions, 0 to hide them

image_height: integer value of image height or null if image dimensions is turned off

image_width: integer value of image width or null if image dimensions is turned off

post_id: ID of current post

post_title: Post title for the image attribute

image_name: Image file name

Example:
add_filter( 'the_content', 'my_custom_post_avatar' );
function my_custom_post_avatar( $content ){
global $post;

$current_avatar = gkl_get_postavatar( $post );
$html_before = '';
$html_after = '
';
// Display default image
if( is_null( $current_avatar ) ) {
$image_url = 'http://wplatest.dev/images/default-image.jpg';
$alt_text = esc_attr(strip_tags($post->post_title) );
} else {
$image_url = $current_avatar['avatar_url'];
$alt_text = $current_avatar['post_title'];
}
$post_avatar_html = $html_before . '' . $alt_text . ''. $html_after;

return $post_avatar_html;
}

OVERRIDE HTML DISPLAY WITH template tag gkl_postavatar
If you want the post avatar to appear outside of the content, e.g. with the entry’s meta information, make use of the gkl_postavatar() template tag.
It takes four paramters:
class: CSS class to use in the `` tag.
before: HTML to appear before the image.
after: HTML to appear after the image.
do_what: Use `echo` to display the post avatar, `return` to pass it to a variable. Defaults to `echo`.

Example: In a template file:

Or you can make your own template tag function like in the example for “Override HTML display with custom content hook”, except you call the function directly in your template instead of hooking into the_content().
For Administration Screens
Add Post Avatar to Pages and Custom Post Types
Use the filter hook gklpa_allowed_post_types to add further post types that you want the Post Avatar selection to appear on.
It takes an array of post type slugs as a parameter.
add_filter( 'gklpa_allowed_post_types', 'prefix_my_custom_post_types' );
function prefix_my_custom_post_types( $current_post_types ){
$current_post_types = array( 'post', 'page', 'review', 'event' );
return $current_post_types;
}

Enable Image Selection for Folder Outside of WordPress Installation
By default, Post Avatar looks for your images folder in relation to your WordPress installation. If you want to move your folder elsewhere, use these pair of filter hooks: gklpa_image_url and gklpa_image_dir. They take a single parameter: Image folder url and absolute path to the image folder, respectively.
add_filter( 'gklpa_image_url', 'prefix_change_folder_url' );
function prefix_change_folder_url( $current_url ){
return esc_url( 'http://mysite.com/images/' );
}

add_filter( 'gklpa_image_dir', 'prefix_change_folder_dir' );
function prefix_change_folder_dir ){
return '/user/public_html/images/';
}

Please visit the Post Avatar Page for details on customizing the avatar display.
Translations
Post Avatar is translation-ready and supports a number of languages. If you can’t find your language here, please consider contributing a language pack.
If you’re interested, please check out the “Codestyling Localization” plugin and for validating the “Poedit Editor”.
Send in your translations to [email protected]
Thanks to the following for their language packs.

Belorussian (ru_RU) Fat Cower
Czech (cz_CZ) Lelkoun
Dutch (nl_NL) Jay August
French (fr_FR) Mathieu Haratyk
German (de_DE) Dominik Menke
Hindi (hi_IN_Hindi) Outshine Solutions
Irish (ga_IR) Ray S.
Italian (it_IT) Gianni Diurno
Polish (pl_PL) Meloniq
Romanian (ro_RO) Webhosting Geeks
Serbo-Croatian (sr_RS) Webhosting Hub
Spanish (es_ES) gogollack

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Post Avatar」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.3 | 1.4 | 1.5 | 1.2.2 | 1.2.3 | 1.2.4 | 1.2.5 | 1.2.7 | 1.3.1 | 1.3.2 | 1.4.1 | 1.4.2 | 1.4.3 | 1.5.1 | 1.6.0 | trunk | 1.2.5.3 | 1.2.5.4 | 1.2.7.1 |

延伸相關外掛(你可能也想知道)

  • Avatar Manager 》WordPress頭像管理員是一款為本地保存頭像等功能的簡單易用的外掛程式。, 通過讓用戶在自己的個人資料屏幕上選擇使用Gravatar還是自託管頭像圖片,您可以增強...。
  • WP First Letter Avatar 》WP First Letter Avatar 可為沒有 Gravatar 的使用者設置自定義頭像。這個頭像將會是使用者名字的第一個字母。您也可以配置外掛程式以使用任何其他字母來設置...。
  • Ultimate Post List 》, , 這個 WordPress 外掛可以輕鬆地製作定制的文章預覽列表,並將它們放置在小工具區域和文章內容中。, 使用多種帖子列表宣傳您的網站內容。無需編程技能。無...。
  • Avatar 》這是一個測試版本。如果有任何錯誤,對不起!請給我留言以回報錯誤。, Avatar 可讓您在管理面板中建立/編輯用戶自訂頭像。使用與 BuddyPress 相同的目錄結構...。
  • IntenseDebate Comments 》IntenseDebate 評論增強和鼓勵您的博客或網站上的互動。與 WordPress 管理面板的自定義整合讓管理成為輕而易舉的事情。評論線程,郵件回覆,用戶帳戶和聲望,...。
  • Letter Avatars 》Letter Avatars 可以讓沒有 Gravatar 的使用者自訂頭像。頭像會被替換成使用者名稱或電子郵件的第一個字母。, Letter Avatars 不使用任何圖片、腳本或字型圖...。
  • Easy Gravatars 》這款外掛可讓您在您的佈景主題中,自動為評論者添加 Gravatar 圖像,如果您的佈景主題不支援 Gravatars 的話。, 根據 Gravatar.com 網站的說法,Gravatar 是...。
  • WP Recent Comments With Avatars 》這款插件是一個輕量級的WordPress外掛程式,可以改寫預設的「最新迴響」小工具,並加入訪客留言的頭像顯示以及引用長度限制為50個字元。, 它是WP_Widget_Rece...。
  • Gravatar Favicon 》這個外掛可以幫助你在網誌和管理頁面中建立一個 gravatar favicon 和包括 Apple touch icon 的管理員標誌。只要啟用這個外掛,它會自動將 gravatars 添加到你...。
  • BuddyPress First Letter Avatar 》BuddyPress First Letter Avatar 是一款能為沒有個人檔案照片或 Gravatar 的使用者設置自定義頭像的 WordPress 外掛。頭像將是使用者名字的首字母。您也可以...。
  • BP Local Avatars 》BP Local Avatars 是一個 BuddyPress 外掛。, 您的 BuddyPress 網站上是否有成員或群組沒有頭像?, 而且您不想顯示通用的預設頭像?, 或者您不想每次瀏覽頁面...。
  • Recent Comments with Avatars 》將這個小工具加到你的側邊欄後,你可以輕鬆地配置它以顯示帶有評論作者頭像的最新評論。選項如下:, , 小工具的標題。, 顯示的評論數量限制 (1 到 15)。, 選...。
  • Gravatar Signup Encouragement 》外掛首頁 | 外掛作者 | 捐贈, 此外掛會顯示帶有連結至 Gravatar 註冊頁面的訊息(已預填電子郵件地址)給沒有 Gravatar 的評論者和/或使用者。, 訊息可以顯示...。
  • Visage 》由於您已找到這個頁面,我猜想您已經注意到目前沒有好用的外掛可用於在後台更改用戶頭像。, visage 有何特色?, , 無需註冊 gravatar 即可更改您的頭像, 為您...。
  • Author Grid 》authorGrid 是一個側邊欄小工具,以網格形式顯示任何在您的網誌上擁有至少一篇已發佈文章的作者頭像。您可以設定頭像的大小,網格中的欄(或列)數量以及小工...。

文章
Filter
Apply Filters
Mastodon