前言介紹
- 這款 WordPress 外掛「Klan1 Common WP Functions」是 2013-11-11 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2015-08-12,距離現在已有 3553 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 2.7 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
klan1 | developer | image resize | basic functions |
內容簡介
這些函式是為了那些需要不斷調整範本或外掛程式圖片大小的人而設計的。
FUNCTION: k1_get_post_thumb_url
DESCRIPTION
string k1_get_post_thumb_url(int $post_id)
該函數將返回文章/頁面所定義的特色圖片(全尺寸),即使上傳不在實際文章中。如果未定義,則返回至少有一個的第一個圖像。
如果沒有jpg、png或gif圖像作為附件,則返回NULL。
用法範例:
參數
$post_id如果為空,我們將嘗試從全局$post變量中獲取POST ID
FUNCTION: k1_get_post_timthumb_img_url
DESCRIPTION
string k1_get_post_timthumb_img_url(int $post_id,int $width,int $height,int $crop,char $align,int $quality)
使用timthumb腳本調整大小的文章特色圖片的全URL將被返回。僅在需要URL而不是IMG html標記時使用此函數。
用法範例:
參數
$post_id如果為空,我們將嘗試從全局$post變量中獲取POST ID
$width這是像素的數字,如果使用0寬度將與高度成比例。請參見:http://www.binarymoon.co.uk/demo/timthumb-basic/
$height這是像素的數字,如果使用0高度將與高度成比例。請參見:http://www.binarymoon.co.uk/demo/timthumb-basic/
$crop使用:0調整大小以適應指定的尺寸(無裁剪),1裁剪並調整尺寸以最佳適配尺寸(默認),2按比例調整大小以將整個圖像放入指定的尺寸並添加邊框(如果需要),3按比例調整大小調整比例,因此沒有邊框間隙。請參閱:http://www.binarymoon.co.uk/demo/timthumb-zoom-crop/
$align在中間的位置:c(這是默認值),t:對齊頂部,tr:對齊右上角,tl:對齊左上角,b:對齊底部,br:對齊右下角,bl:對齊左下角,l:對齊左側,r:對齊右側。參閱:http://www.binarymoon.co.uk/2010/08/timthumb-part-4-moving-crop-location/
$quality 70:百分比,最初上傳的圖像的圖像質量
注意:如果只定義一個為零的高度或寬度,另一個將保持圖像比例,如果未定義,則為默認值。
FUNCTION: k1_get_post_thumb_img_html
DESCRIPTION
string k1_get_post_thumb_img_html(int $post_id,boolean $resize,int $width,int $height,int $crop,char $align,int $quality)
使用TIMTHUMB或不使用所需的話,此函數將返回文章特色圖片的FULL IMG HTML標記。
用法範例:
參數
$post_id如果為空,我們將嘗試從全局$post變量中獲取POST ID
$resizeTRUE使用timthumb腳本調整圖像大小,FALSE返回沒有任何尺寸更改的圖像。
$width這是像素的數字,如果使用0寬度將與高度成比例。請參見:http://www.binarymoon.co.uk/demo/timthumb-basic/
$height這是像素的數字,如果使用0高度將與高度成比例。請參見:http://www.binarymoon.co.uk/demo/timthumb-basic/
$crop使用:0調整大小以適應指定的尺寸(無裁剪),
原文外掛簡介
This functions are for those needs to resize images on their templates or plugins all the time.
FUNCTION: k1_get_post_thumb_url
DESCRIPTION
string k1_get_post_thumb_url(int $post_id)
This function return the URL for the FEATURED IMAGE (full sized) defined in a POST/PAGE even if the upload is no on the actual post. If is not defined returns the FIRST image if there is at least one.
Returns NULL if no jpg,png or gif images as attachments.
USAGE EXAMPLE
PARAMETERS
$post_id If is empty, we will try to get the POST ID from the global $post var
FUNCTION: k1_get_post_timthumb_img_url
DESCRIPTION
string k1_get_post_timthumb_img_url(int $post_id, int $width, int $height, int $crop, char $align, int $quality)
Returns the IMAGE full URL using timthumb script to resize the post featured image. Use this when you only need the URL not the IMG html tag.
USAGE EXAMPLE
PARAMETERS
$post_id If is empty, we will try to get the POST ID from the global $post var
$width This is numeric in pixels, if you use 0 width will be proportional to height. See: http://www.binarymoon.co.uk/demo/timthumb-basic/
$height This is numeric in pixels, if you use 0 height will be proportional to height. See: http://www.binarymoon.co.uk/demo/timthumb-basic/
$crop Use: 0 Resize to Fit specified dimensions (no cropping), 1 Crop and resize to best fit the dimensions (default), 2 Resize proportionally to fit entire image into specified dimensions, and add borders if required, 3 Resize proportionally adjusting size of scaled image so there are no borders gaps, see: http://www.binarymoon.co.uk/demo/timthumb-zoom-crop/
$align c : position in the center (this is the default), t : align top, tr : align top right, tl : align top left, b : align bottom, br : align bottom right, bl : align bottom left, l : align left, r : align rightSee: http://www.binarymoon.co.uk/2010/08/timthumb-part-4-moving-crop-location/
$quality 70 : Image quality from the original uploaded image in percentage
NOTE: If you just define one height or width as zero (0) the other one will conserve image proportion, if is not defined it will be default value.
FUNCTION: k1_get_post_thumb_img_html
DESCRIPTION
string k1_get_post_thumb_img_html(int $post_id, boolean $resize, int $width, int $height, int $crop, char $align, int $quality)
This function returns the FULL IMG HTML tag for the post featured image using TIMTHUMB or not as desired
USAGE EXAMPLE
PARAMETERS
$post_id If is empty, we will try to get the POST ID from the global $post var
$resize TRUE to use timthumb script to resize the image, FALSE to return the image without any dimension change.
$width This is numeric in pixels, if you use 0 width will be proportional to height. See: http://www.binarymoon.co.uk/demo/timthumb-basic/
$height This is numeric in pixels, if you use 0 height will be proportional to height. See: http://www.binarymoon.co.uk/demo/timthumb-basic/
$crop Use: 0 Resize to Fit specified dimensions (no cropping), 1 Crop and resize to best fit the dimensions (default), 2 Resize proportionally to fit entire image into specified dimensions, and add borders if required, 3 Resize proportionally adjusting size of scaled image so there are no borders gaps, see: http://www.binarymoon.co.uk/demo/timthumb-zoom-crop/
$align c : position in the center (this is the default), t : align top, tr : align top right, tl : align top left, b : align bottom, br : align bottom right, bl : align bottom left, l : align left, r : align rightSee: http://www.binarymoon.co.uk/2010/08/timthumb-part-4-moving-crop-location/
$quality 70 : Image quality from the original uploaded image in percentage
NOTE: If you just define one height or width as zero (0) the other one will conserve image proportion, if is not defined it will be default value.
TODO:
Get the attachment metadata to make the longdesc=”” and alt=”” IMG properties.
Use the parameters as array to implement more options
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Klan1 Common WP Functions」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Klan1 WP List Subpages 》重要訊息:此外掛需要 Klan1 Common WP Functions 外掛:https://wordpress.org/plugins/klan1-functions/, 用法, , [k1-list-pages mode=table], [k1-list-p...。