前言介紹
- 這款 WordPress 外掛「Kama Thumbnail」是 2015-08-03 上架。
- 目前有 10000 個安裝啟用數。
- 上一次更新是 2023-03-22,距離現在已有 772 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.7 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 7.1 以上。
- 有 15 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
tkama |
外掛標籤
內容簡介
這個外掛可以方便地在不增加負擔的情況下即時建立文章縮圖,是 "thumbnail.php" 腳本的最佳替代品。
支援多站點。
使用方法
這是針對開發人員的外掛,安裝後不會直接執行任何操作。為了讓外掛正常運作,你需要在你的佈景主題或外掛中使用其中一個外掛函式。例如:
使用這段代碼可以在迴圈中獲取準備好的文章縮圖 IMG 標籤。插件會獲取文章縮略圖或是在文章內容中找到第一張圖片,將其調整大小並建立快取。同時,插件會為文章創建一個自定義欄位,其中包含原始圖片的 URL。換句話說,插件會將所有的程序都快取下來,在下一次加載網頁時直接使用快取結果。
你也可以根據自定義的 URL 來製作縮圖,像這樣:
URL_TO_IMG 必須來自本地伺服器,默認情況下,此插件無法處理外部圖片,因為涉及到安全問題。但是可以在設置頁面上設置允許的主機: 設置 > 媒體。
所有的插件函式:
// 返回縮略圖 URL
echo kama_thumb_src( $args, $src );
// 返回縮略圖 IMG
echo kama_thumb_img( $args, $src );
// 返回縮略圖 IMG 标签包裹的链接。 鏈接到原始圖片。
echo kama_thumb_a_img( $args, $src );
// 可以在縮略圖創建後獲得圖像的寬度或高度
echo kama_thumb( $optname );
// Ex:
echo '';
參數:
$args (array/string)
用來創建縮略圖的參數。接受:
w | width
(int) 想要縮略的寬度。
h | height
(int) 想要縮略的高度。
如果沒有設置 w 和 h 參數,那麼它們均為 100 - 方形縮略圖 100x100 px。
notcrop
(isset) 如果設置,crop 參數變為false,即 crop=false。
crop
(isset) 控制圖像裁剪。默認情況下永遠為 true。
要禁用裁剪,請設置為 false/0/no/none 或設置參數 'notcrop'。然後,圖像將不會被裁剪並將被創建作為原始圖像的大小設置的小副本:寬度或高度 - 插件會選擇最小適合的側面。因此,一個側面會按照設置的 w 或 h 進行設置,而另一個側面會小於 w 或 h。
裁剪位置
同時,您可以指定字符串: 'top'、'bottom'、'left'、'right' 或 'center' 以及由此字符串黏合的任何其他組合。例如:'right/bottom'。所有這些都將設置裁剪區域:
'left', 'right' – 水平側面(w)
'top', 'bottom' – 垂直側面(h)
'center' – 對於兩側(w和h)
當僅設置一個值時,另一個值將默認。預設為:'center/center'。
範例:
// 圖像將按縮小高度,並裁剪寬度。
// “right” 意味著會顯示圖像的右側,左側將被裁剪。
kama_thumb_img('w=200 &h=400 &crop=right');
// 圖像將按縮小寬度,並裁剪高度。
// “top” 意味著圖像的頂部將被顯示,底部將被裁剪。
kama_thumb_img('w=400 &h=300 &crop=top');
$src
(str)需要創建縮略圖的圖像 URL。如果未指定,插件將嘗試獲取文章中的圖像和縮略圖。
$optname
(str) 要獲取寬度或高度的選項名稱。可選的值: 'width', 'height'。
原文外掛簡介
Convenient way to create post thumbnails on the fly without server overload.
The best alternative to scripts like “thumbnail.php”.
Supports Multisite.
Usage
The plugin for developers firstly, because it don’t do anything after install. In order to the plugin begin to work, you need use one of plugin function in your theme or plugin. Example:
Using the code in the loop you will get ready thumbnail IMG tag. Plugin takes post thumbnail image or find first image in post content, resize it and create cache. Also creates custom field for the post with URL to original image. In simple words it cache all routine and in next page loads just take cache result.
You can make thumbs from custom URL, like this:
The URL_TO_IMG must be from local server: by default, plugin don’t work with external images, because of security. But you can set allowed hosts on settings page: Settings > Media.
All plugin functions:
// return thumb url URL
echo kama_thumb_src( $args, $src );
// return thumb IMG tag
echo kama_thumb_img( $args, $src );
// return thumb IMG tag wraped with . A link of A will leads to original image.
echo kama_thumb_a_img( $args, $src );
// to get image width or height after thumb creation
echo kama_thumb( $optname );
// ex:
echo '';
Parameters:
$args (array/string)
Arguments to create thumb. Accepts:
w | width
(int) desired width.
h | height
(int) desired height.
if parameters w and h not set, both of them became 100 – square thumb 100х100 px.
notcrop
(isset) if set crop parameter become false – crop=false.
crop
(isset) Control image cropping. By default always true.
To disable cropping set here false/0/no/none or set parameter 'notcrop'. Then image will not be cropped and will be created as small copy of original image by sizes settings of one side: width or height – here plugin select the smallest suitable side. So one side will be as it set in w or h and another side will be smaller then w or h.
Cropping position
Also, you can specify string: 'top', 'bottom', 'left', 'right' or 'center' and any other combinations of this strings glued with /. Ex: 'right/bottom'. All this will set cropping area:
'left', 'right' – horizontal side (w)
'top', 'bottom' – vertical side (h)
'center' – for both sides (w and h)
When only one value is set, the other will be by default. By default: 'center/center'.
Examples:
// image will be reduced by height, and width will be cropped.
// "right" means that right side of image will be shown and left side will be cut.
kama_thumb_img('w=200 &h=400 &crop=right');
// image will be redused by width, and height will be cropped.
// "top" means that the top of the image will be shown and bottom side will be cut.
kama_thumb_img('w=400 &h=200 &crop=top');
// you can specify two side position at once, order doesn't matter
kama_thumb_img('w=400 &h=200 &crop=top/right');
Reduce image by specified side
In order to get not cropped proportionally rediced image by specified side: by width or height. You need specify only width or only height, then other side will be reduced proportional. And no cropping will appear here.
kama_thumb_img('w=200');
So, width of our image will be 200, and height will be as it will…
Теперь ширина всегда будет 200, а высота какая получится… And the picture will be always full, without cropping.
q | quality
(int) jpg compression quality (Default 85. max.100)
stub_url
(string) URL to no_photo image.
alt
(str) alt attr of img tag.
title
(str) title attr of img tag.
class
(str) class attr of img tag.
style
(str) style attr of img tag.
attr
(str) Allow to pass any attributes in IMG tag. String passes in IMG tag as it is, without escaping.
a_class
(str) class attr of A tag.
a_style
(str) style attr of A tag.
a_attr
(str) Allow to pass any attributes in A tag. String passes in A tag as it is, without escaping.
no_stub
(isset) don’t show picture stub if there is no picture. Return empty string.
yes_stub
(isset) show picture stub if global option in option disable stub showing, but we need it…
post_id | post
(int|WP_Post) post ID. It needs when use function not from the loop. If pass the parameter plugin will exactly knows which post to process. Parametr ‘post’ added in ver 2.1.
attach_id
(int) ID of wordpress attachment image. Also, you can set this parametr by pass attachment ID to ‘$src’ parament – second parametr of plugin functions: kama_thumb_img('h=200', 250) or kama_thumb_img('h=200 &attach_id=250')
allow
(str) Which hosts are allowed. This option sets globally in plugin setting, but if you need allow hosts only for the function call, specify allow hosts here. Set ‘any’ to allow to make thumbs from any site (host).
$src
(string) URL to any image. In this case plugin will not parse URL from post thumbnail/content/attachments.
If parameters passes as array second argument $src can be passed in this array, with key: src или url или link или img:
echo kama_thumb_img( array(
'src' => 'http://yousite.com/IMAGE_URL.jpg',
'w' => 150,
'h' => 100,
) );
Notes
You can pass $args as string or array:
// string
kama_thumb_img('w=200 &h=100 &alt=IMG NAME &class=aligncenter', 'IMG_URL');
// array
kama_thumb_img( array(
'width' => 200,
'height' => 150,
'class' => 'alignleft'
'src' => ''
) );
You can set only one side: width | height, then other side became proportional.
src parameter or second function argument is for cases when you need create thumb from any image not image of WordPress post.
For test is there image for post, use this code:
if( ! kama_thumb_img('w=150&h=150&no_stub') )
echo 'NO img';
Examples
#1 Get Thumb
In the loop where you need the thumb 150х100:
Result:
#2 Not show stub image
#3 Get just thumb URL
Result: /wp-content/cache/thumb/ec799941f_100x80.png
This url you can use like:
' alt=''>
#4 kama_thumb_a_img() function
#5 Thumb of any image URL
Pass arguments as array:
'http://yousite.com/IMAGE_URL.jpg',
'w' => 150,
'h' => 100,
) );
?>
Pass arguments as string:
When parameters passes as string and “src” parameter has additional query args (“src=$src &w=200” where $src = http://site.com/img.jpg?foo&foo2=foo3) it might be confuse. That’s why “src” parameter must passes as second function argument, when parameters passes as string (not array).
#6 Parameter post_id
Get thumb of post ID=50:
I don’t need plugin
This plugin can be easily used not as a plugin, but as a simple php file.
If you are themes developer, and need all it functionality, but you need to install the plugin as the part of your theme, this short instruction for you:
Create folder in your theme, let it be ‘thumbmaker’ – it is for convenience.
Download the plugin and copy the files: class.Kama_Make_Thumb.php and no_photo.jpg to the folder you just create.
Include class.Kama_Make_Thumb.php file into theme functions.php, like this:
require ‘thumbmaker/class.Kama_Make_Thumb.php’;
Bingo! Use functions: kama_thumb_*() in your theme code.
If necessary, open class.Kama_Make_Thumb.php and edit options (at the top of the file): cache folder URL/PATH, custom field name etc.
Conditions of Use – mention of this plugin in describing of your theme.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Kama Thumbnail」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
2.5 | 2.5.1 | 2.5.8 | 2.6.0 | 2.6.3 | 2.7.2 | 2.7.6 | 3.3.7 | 3.3.8 | 3.4.0 | 3.4.1 | 3.4.2 | 3.5.0 | 3.5.1 |
延伸相關外掛(你可能也想知道)
Image Optimization by Optimole – Lazy Load, CDN, Convert WebP & AVIF, Optimize Images 》, Optimole的獨特之處在哪裡?, , 更小的圖片,同樣的品質, 完全自動化;設定一次就忘記它, 支援所有圖片格式, 支援Retina和WebP圖片, 以機器學習為基礎的自...。
Imsanity 》使用 Imsanity,自動調整大型圖片上傳大小。選擇你喜歡的尺寸和品質,讓 Imsanity 完成其餘所有工作。當投稿者上傳大於配置尺寸的圖片時,Imsanity 將自動將...。
Firelight Lightbox 》Easy FancyBox WordPress外掛為您的網站提供靈活美觀的光箱解決方案,幾乎適用於網站上的所有媒體連結。Easy FancyBox使用更新的傳統FancyBox jQuery擴展版本...。
Simple Lightbox 》Simple Lightbox 是一個非常簡單且可自定義的燈箱,在您的 WordPress 網站上添加它非常容易。, 功能, 自定義燈箱行為的選項位於外觀 > Lightbox 管理員菜...。
Robin image optimizer — save money on image compression 》需要專業支援嗎?, 開始免費支援, 開始高級支援, 透過減少圖像大小,讓您的網站加快速度。我們的 WordPress 圖像優化外掛,可以將圖像大小減少80%,而且不損...。
Responsive Lightbox & Gallery 》提供完整的 WordPress 相簿外掛所需一切, Responsive Lightbox and Gallery 外掛是一個全功能的 WordPress 相簿外掛,擁有強大的拖放相簿生成器和 Lightbox ...。
reSmush.it : The original free image compressor and optimizer plugin 》reSmush.it Image Optimizer 是一個 WordPress 外掛,透過 reSmush.it API 提供圖片優化服務。reSmush.it 使用多種高級演算法對圖像進行大小減小。API 支援最...。
Menu Image, Icons made easy 》這個外掛可以輕鬆地在選單項目中加入圖像或圖示,打造更好的網站選單。, 可以控制圖像或圖示的位置以及大小。, 這個 Menu Image 外掛還有其他功能,以下是其...。
Image Widget 》Image Widget 是一個簡單的外掛程式,利用 WordPress 原生媒體管理員,為您的網站新增圖片小工具。, 需要新增幻燈片、燈箱或隨機圖像嗎?, 請查看 Image Widg...。
Featured Image from URL (FIFU) 》h3>WordPress 外掛 - 用於顯示外部特色圖片、影片、音訊等等, FIFU 自 2015 年來已幫助全球數千個網站節省了儲存空間、處理時間和版權費用。, 如果您已經厭倦...。
Default Featured Image 》在媒體設定頁面上新增一個預設的特色圖像。如果沒有設定任何特色圖像,這個預設的特色圖像就會顯示。就這麼簡單。, 查看常見問題以獲取基本問題資訊。, 如果...。
All In One Favicon 》查看最新的WordPress交易以優化您的網站。, All In One Favicon為您的網站和管理頁面添加favicon。, 您可以使用您已經上傳的favicon或使用內置的上傳機制將fa...。
ImageMagick Engine 》透過讓 WordPress 使用 ImageMagick 而非標準的 GD 圖像庫,大幅提升重新調整大小的圖像品質。, 功能, , 在重新調整大小的圖像中保留嵌入式色彩設定檔, 自動...。
WP Featherlight – A Simple jQuery Lightbox 》WP Featherlight 是一個 WordPress 外掛,可為您的WordPress 網站添加一個極簡、高效、響應式 jQuery 燈箱。在其核心,WP Featherlight是一個用於 Featherlig...。
Phoenix Media Rename 》通過使用「Phoenix Media Rename」外掛,將您的媒體檔案重新命名,極大地提高您的 SEO。, 在Phoenix Media Rename 官方頁面上提供了完整的使用和設置指南。。