內容簡介
這個 WordPress 外掛可讓您上傳類別和自訂分類法的圖像,並提供一個範本標籤在主題中顯示該圖像。要啟用自訂分類法的圖像,請前往「設定 > Category Images II」。要上傳類別或自訂分類法中的標籤圖像,請前往該類別或標籤的編輯螢幕。
標籤:ciii_category_images()和ciii_term_images()
在迴圈內使用上述範本標籤將會顯示該文章類別的所有類別圖像縮圖。如果某些類別沒有圖像,則不會顯示圖像(即沒有預設圖像)。您需要自己設定 HTML 輸出樣式。
提供類別 ID,任何位置都可使用上述範本標籤,將會顯示所有指定的類別的縮圖。如果某些類別沒有圖像,則不會顯示圖像(即此處也沒有預設圖像)。
(注意,如果您在迴圈之外使用此標籤,它會變得混亂。如果您想在類別存檔頁面中添加單一圖像,請使用下面的iii_category_archive_image()標籤。)
在迴圈內使用上述範本標籤將會顯示與該文章關聯的指定分類法(在此範例中為「post_tag」)的所有標籤圖像縮圖。如果某些標籤沒有圖像,則不會顯示圖像(即沒有預設圖像)。您需要自己設定 HTML 輸出樣式。
提供標籤 ID,任何位置都可使用上述範本標籤,將會顯示所有指定的標籤的縮圖。如果某些標籤沒有圖像,則不會顯示圖像(即此處也沒有預設圖像)。您需要自己設定 HTML 輸出樣式。您可以傳遞show_description參數以不顯示標籤或類別說明,size參數以指定「原始」或「縮圖」。
標籤:ciii_category_archive_image()
此標籤設計用於類別存檔頁面,內部或外部迴圈均可使用。它會顯示該類別的圖像。您可以在「設定 > Category Images II」中指定類別圖像縮圖的最大邊長。您可以從「管理 > 分類」中為每個類別上傳和刪除圖像,點擊要編輯的每個類別即可看到上傳和刪除控制元件(只有在分類已經上傳圖像後才會顯示刪除控制元件)。
HTML 輸出非常良好,但如果您需要調整它,可以創建一個名為「view」的主題目錄,以及其內部名為「category-images-ii」的目錄。然後從外掛目錄中複製範本檔案view/category-images-ii/term-images.php到您的主題目錄中,並進行修改。如果這些檔案在主題目錄的這些目錄中存在,它們將覆蓋外掛目錄中的檔案。這很好,因為這意味著當您更新外掛時,您只需覆蓋舊的外掛目錄,因為您沒有更改任何檔案。感謝 John Godley 提供此幻想程式碼。這個外掛是代表 Puffbox 製作的。
外掛標籤
開發者團隊
原文外掛簡介
This plugin allows you to upload images for categories and custom taxonomies, and provides a template tag to show the image(s) in your theme.
To activate the images for a custom taxonomy, go to Settings > Category Images II.
To upload an image for a category, or a term in a custom taxonomy, go to the edit screen for that category or term.
Tag: ciii_category_images() && ciii_term_images()
Used within the loop, the above template tag will show the thumbnails for all the category images for the category of that post. If some categories have no image, no image is shown for that category (i.e. there is no default image). You will need to style the HTML output yourself.
Used anywhere and provided with category IDs, the above template tag will show the thumbnails for all the categories specified. If some categories have no image, no image is shown for that category (i.e. there is no default image here either).
(Note that this tag will get confused if you use it outside the loop. If you want to add a single image to your category archive pages, please use ciii_category_archive_image() below.)
Used within the loop, the above template tag will show the thumbnails for all the term images for the specified taxonomy (in this case ‘post_tag’) which are associated with that post. If some terms have no image, no image is shown for that term (i.e. there is no default image). You will need to style the HTML output yourself.
Used anywhere and provided with term IDs, the above template tag will show the thumbnails for all the terms specified. If some terms have no image, no image is shown for that term (i.e. there is no default image here either). You will need to style the HTML output yourself.
You can pass the show_description parameter to not show the term or category description, and the size parameter to specify either ‘original’ or ‘thumbnail’.
Tag: ciii_category_archive_image()
This tag is designed to be used on the category archive page, either inside or outside the loop. It will show the image for the category in question.You can specify the maximum side of the category image thumbnail in “Settings > Category Images II”. You can upload, and delete, images for each category from “Manage > Categories”, click into each category you wish to edit and you’ll see the uploading and deletion controls (deletion controls only show up if the category already has an image uploaded).
The HTML output is fairly well classed, but if you need to adapt it you can. Create a directory in your theme called “view”, and a directory within that one called “category-images-ii”. Then copy the template files view/category-images-ii/term-images.php from the plugin directory into your theme directory and amend as you need. If these files exist in these directories in your theme they will override the ones in the plugin directory. This is good because it means that when you update the plugin you can simply overwrite the old plugin directory as you haven’t changed any files in it. All hail John Godley for the code which allows this magic to happen.
Plugin initially produced on behalf of Puffbox.
Is this plugin lacking a feature you want? I’m happy to accept offers of feature sponsorship: contact me and we can discuss your ideas.
Any issues: contact me.
