前言介紹
- 這款 WordPress 外掛「Taxonomy Images」是 2010-02-13 上架。
- 目前有 10000 個安裝啟用數。
- 上一次更新是 2024-02-15,距離現在已有 446 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.4 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 5.3 以上。
- 有 40 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
husobj | mfields | jamiemchale |
外掛標籤
tag | term | image | category | taxonomy |
內容簡介
在你的主題中顯示圖像
有一些過濾器可以在你的主題中使用,來顯示此外掛創建的圖像關聯。請閱讀以下詳細信息。
顯示代表術語檔案庫的單個圖像
以下過濾器將顯示與URL查詢字符串中要求的術語關聯的圖像。此過濾器僅在自然使用模板的視圖中工作,如category.php、tag.php、taxonomy.php和它們的衍生物。請閱讀有關這些模板的模板層次結構以獲取更多信息。這個過濾器的最簡單用法如下所示:
print apply_filters( 'taxonomy-images-queried-term-image', '' );
這段代碼將生成並打印一個圖像標籤。它的輸出可以通過將可選的第三個參數傳遞給apply_filters()來修改。此參數是一個數組,以下鍵可以設置:
after(字符串)--要附加到圖像HTML的文本。
attr(數組)--表示img標籤的屬性的key/value對。可用的選項包括:alt、class、src和title。此數組將不加修改作為第四個參數傳遞給WordPress核心函數wp_get_attachment_image()。
before(字符串)--要向圖像HTML前面添加的文本。
image_size(字符串)--可以是在WordPress註冊的任何圖像大小。如果沒有指定圖像大小,將使用“thumbnail”作為默認值。如果指定了未註冊的大小,此過濾器將返回一個空字符串。
這是一個完全自定義版本的此過濾器的示例:
print apply_filters( 'taxonomy-images-queried-term-image', '', array(
'attr' => array(
'alt' => '自訂替代文字',
'class' => 'my-class-list bunnies turtles',
'src' => '這是圖像存放的地方.png',
'title' => '自訂標題',
),
'before' => '
'after' => '
'image_size' => 'medium'
) );
相似的功能
如果你只需要獲取圖像的數據庫ID,可以使用:
$image_id = apply_filters( 'taxonomy-images-queried-term-image-id', 0 );
如果你需要獲取圖像的完整對象,可以使用:
$image = apply_filters( 'taxonomy-images-queried-term-image-object', '' );
如果你需要獲取圖像的URL,可以使用以下方法:
$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '' );
你可以在可選的第三個參數中指定圖像的大小:
$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '', array(
'image_size' => 'medium'
) );
如果你需要獲取圖像數據,可以使用:
$image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '' );
你可以在可選的第三個參數中指定圖像的大小:
$image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '', array(
'image_size' => 'medium'
) );
列出與文章對象關聯的術語圖像
當你想要在文章內顯示所有與其關聯的術語圖像時,可以使用以下內容:
print apply_filters( 'taxonomy-images-list-the-terms', $post->ID, array( 'size' => 'thumbnail', 'orderby' => 'name', 'order' => 'ASC', 'style' => 'display:inline-block;', 'separator' => ', ', 'before' => '', 'after' => '' ) );
原文外掛簡介
Displaying Your Images in Your Theme
There are a few filters that you can use in your theme to display the image associations created by this plugin. Please read below for detailed information.
Display a single image representing the term archive
The following filter will display the image associated with the term asked for in the query string of the URL. This filter only works in views that naturally use templates like category.php, tag.php, taxonomy.php and all of their derivatives. Please read about template hierarchy for more information about these templates. The simplest use of this filter looks like:
print apply_filters( 'taxonomy-images-queried-term-image', '' );
This code will generate and print an image tag. It’s output can be modifed by passing an optional third parameter to apply_filters(). This parameter is an array and the following keys may be set:
after (string) – Text to append to the image’s HTML.
attr (array) – Key / value pairs representing the attributes of the img tag. Available options include: alt, class, src and title. This array will be passed as the fourth parameter to WordPress core function wp_get_attachment_image() without modification.
before (string) – Text to prepend to the image’s HTML.
image_size (string) – May be any image size registered with WordPress. If no image size is specified, ‘thumbnail’ will be used as a default value. In the event that an unregistered size is specified, this filter will return an empty string.
Here’s an example of what a fully customized version of this filter might look like:
print apply_filters( 'taxonomy-images-queried-term-image', '', array(
'attr' => array(
'alt' => 'Custom alternative text',
'class' => 'my-class-list bunnies turtles',
'src' => 'this-is-where-the-image-lives.png',
'title' => 'Custom Title',
),
'before' => '
'after' => '
',
'image_size' => 'medium'
) );
Similar functionality
If you just need to get the database ID for the image, you may want to use:
$image_id = apply_filters( 'taxonomy-images-queried-term-image-id', 0 );
If you need to get the full object of the image, you may want to use:
$image = apply_filters( 'taxonomy-images-queried-term-image-object', '' );
If you need to get the URL to the image, you may want to use the following:
$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '' );
You can specify the size of the image in an option third parameter:
$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '', array(
'image_size' => 'medium'
) );
If you need data about the image, you may want to use:
$image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '' );
You can specify the size of the image in an option third parameter:
$image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '', array(
'image_size' => 'medium'
) );
List term images associated with a post object
When a post is being displayed you may want to display the images associated with all of the terms associated with the post. The taxonomy-images-list-the-terms filter does this. Here’s what it looks like in its simplest form:
print apply_filters( 'taxonomy-images-list-the-terms', '' );
This filter accepts an optional third parameter that you can use to customize its output. It is an array which recognizes the following keys:
after (string) – Text to append to the output. Default value is a closing unordered list tag.
after_image (string) – Text to append to each image. Default value is a closing list-item tag.
before (string) – Text to prepend to the output. Default value is an open unordered list tag with an class attribute of “taxonomy-images-the-terms”.
before_image (string) – Text to prepend to each image. Default value is an open list-item tag.
image_size (string) – Any registered image size. Values will vary from installation to installation. Image sizes defined in core include: “thumbnail”, “medium” and “large”. “full” may also be used to get the unmodified image that was uploaded. Defaults to “thumbnail”.
post_id (int) – The post to retrieve terms from. Defaults to the ID property of the global $post object.
taxonomy (string) – Name of a registered taxonomy to return terms from. Defaults to category.
Here’s an example of what a fully customized version of this filter might look like:
print apply_filters( 'taxonomy-images-list-the-terms', '', array(
'before' => '
'after' => '
',
'before_image' => '',
'after_image' => '',
'image_size' => 'detail',
'post_id' => 1234,
'taxonomy' => 'post_tag',
) );
Working with all terms of a given taxonomy
You will want to use the taxonomy-images-get-terms filter. This filter is basically a wrapper for WordPress core function get_terms(). It will return an array of enhanced term objects: each term object will have a custom property named image_id which is an integer representing the database ID of the image associated with the term. This filter can be used to create custom lists of terms. Here’s what it’s default useage looks like:
$terms = apply_filters( 'taxonomy-images-get-terms', '' );
Here is what php’s print_r() function may return:
Array
(
[0] => stdClass Object
(
[term_id] => 8
[name] => Pirate
[slug] => pirate
[term_group] => 0
[term_taxonomy_id] => 8
[taxonomy] => category
[description] => Pirates live in the ocean and ride around on boats.
[parent] => 0
[count] => 1
[image_id] => 44
)
)
As you can see, all of the goodness of get_terms() is there with an added bonus: the image_id parameter!
This filter recognizes an optional third parameter which is an array of arguments that can be used to modify its output:
cache_images (bool) If this value is true all associated images will be queried and cached for later use in various template tags. If it is set to false, this query will be suppressed. Do not set this value to false unless you have a really good reason for doing so 🙂 Default value is true.
having_images (bool) If this value is true then only terms that have associated images will be returned. Setting it to false will return all terms. Default value is true.
taxonomy (string) Name of a registered taxonomy to return terms from. Multiple taxonomies may be specified by separating each name by a comma. Defaults to category.
term_args (array) Arguments to pass to get_terms() as the second parameter. Default value is an empty array.
Here’s an example of a simple custom loop that you can use to display all term images:
$terms = apply_filters( 'taxonomy-images-get-terms', '' );
if ( ! empty( $terms ) ) {
print '
- ';
- ' . wp_get_attachment_image( $term->image_id, 'detail' ) . '
foreach ( (array) $terms as $term ) {
print '
';
}
print '
';
}
Support
If you have questions about integrating this plugin into your site, please add a new thread to the WordPress Support Forum. I try to answer these, but I may not always be able to. In the event that I cannot there may be someone else who can help.
Bugs, Suggestions
Development of this plugin is hosted in a public repository on Github. If you find a bug in this plugin or have a suggestion to make it better, please create a new issue
Hook it up yo!
If you have fallen in love with this plugin and would not be able to sleep without helping out in some way, please see the following list of ways that you can hook it up!:
Rate it! – Use the star tool on the right-hand sidebar of the plugin homepage.
Let me know if it works – Use the Compatibility widget on the plugin homepage to let everyone know that the current version works with your version of WordPress.
Do you Twitter? Help promote by using this shortlink: http://bit.ly/taxonomy-images
Are you a writer? Help promote by writing an article on your website about this plugin.
Need More Taxonomy Plugins?
The original author of this plugin, Michael Fields, released a handful of plugins dealing with taxonomies. Please see his WordPress.org profile for more information.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Taxonomy Images」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.9 | 1.0 | 0.8.0 | 0.9.1 | 0.9.2 | 0.9.3 | 0.9.4 | 0.9.5 | 0.9.6 | 0.9.7 | trunk |
延伸相關外掛(你可能也想知道)
Pages with category and tag 》在頁面中新增分類和標籤。。
WordPress Tag, Category, and Taxonomy Manager – AI Autotagger 》axoPress allows you to show a customizable display of the terms assigned to the current post. You can choose which taxonomy and which format to dis...。
WP Translitera 》這是一個可用於轉換文章、頁面、標籤、媒體和檔案等永久連結的轉換插件。, This is a transliteration plugin that can convert permanent links of posts, p...。
WP No Base Permalink 》該外掛能夠將分類基礎從您的分類永久連結中移除 (可選)。默認情況下啟用。, 該外掛能夠從您的分類永久連結中移除父級分類 (可選)。, 該外掛能夠將標籤基礎從...。
Term Management Tools 》請注意,此外掛需要至少 PHP 7.1。, 如果您需要重新組織標籤和分類,此外掛可以讓您更輕鬆地進行操作。它在條目管理頁面的“批次操作”下拉菜單中添加了三個新...。
PS Taxonomy Expander 》PS Taxonomy Expander 可以讓您更輕鬆地在編輯文章時使用類別、標籤和自訂分類法。, 功能, , 啟用將分類法核取方塊變成有階層的單選按鈕功能。, 讓您在 WordP...。
Cool Tag Cloud 》此外掛會以專業設計的標籤圖像作為背景,呈現標籤雲。, 此外掛的標籤雲具有完全回應式設計,可在所有瀏覽器中正確顯示。, 此外掛的主要使用方式是透過「Cool ...。
Category Tag Pages 》為您的頁面添加類別和標籤功能。, 此外掛會添加「post_tag」和「category」taxonomy (標籤和分類所使用的現有taxonomy名稱) 到「page」文章型別 (Post type) ...。
All Meta Tags 》這是一款易於使用、界面直觀的 WordPress 外掛程式,可以讓您輕鬆而安全地在 WordPress 管理區中直接添加自訂 Meta 標籤,而無需使用外部編輯器。, , 此工具...。
Remove Taxonomy Base Slug 》如果您想要對您的自訂文章類型文章使用更好的固定連結,並使用自訂的固定連結,這個外掛程序可以協助您。, 如果該術語的slug和文章類型相同,那麼該分類的優...。
Format Media Titles 》格式化媒體標題 WordPress 外掛可以讓你為新上傳的媒體項目格式化標題。手動編輯新上傳的媒體項目的標題可能會相當繁瑣。這個外掛可以自動從標題中刪除和替換...。
WordPress Ad Widget 》這是在您的 WordPress 網站上放置廣告最簡單的方法。只需將小工具拖到側邊欄中,上傳廣告,然後保存即可。, 觀看一個短視頻演示:https://youtu.be/E9CC3ZWOa...。
Auto Tag Creator 》這個外掛在儲存文章/產品標題和分類時,會自動將其中的關鍵字轉換為標籤。它包含了一個可供使用者編輯的詞彙忽略清單。其他特點如下:, , , 將文章/產品標題...。
Taxonomy Switcher 》這個外掛允許您選擇您的「From」和「To」分類法,以轉換所有項目。選擇一個父項可以選擇轉換項目的範圍。在輸入名稱時,將會即時搜尋包含特定名稱和子項目的...。
Taxonomy List Widget 》此外掛可建立非階層式分類法(例如文章標籤)的列表,讓使用者不用使用詞彙雲也能輕鬆檢視分類法。可使用多個不同的小工具,每個小工具都有自己的設定。, 提...。