[WordPress] 外掛分享: Grayscale

首頁外掛目錄 › Grayscale
WordPress 外掛 Grayscale 的封面圖片
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
100+
安裝啟用
尚無評分
4524 天前
最後更新
問題解決
WordPress 3.0.1+ v1.2 上架:2012-09-30

內容簡介

有時,您的網站設計需要把圖片轉換成黑白:例如在圖片庫顯示中,您可以將所有縮略圖設置為灰階,當滑鼠懸停在圖片上時,將其變回彩色。
這個外掛可以讓您不需要手動為每個圖片創建灰階變體就能夠實現該效果。

在您的主題的functions.php中,不要使用 WordPress add_image_size函數,而是使用grayscale_add_image_size('custom_size', xxx, yyy, $crop, $grayscale)(如果要裁剪圖像,將$crop設置為true,如果要灰度版本的圖像,則將$grayscale設置為true)。然後,您可以使用the_post_thumbnail或任何縮略圖函數來獲取您的灰階圖像:

the_post_thumbnail('custom_size-gray')

一個伽瑪校正自動應用于黑白圖像,以使它們看起來美觀。從 1.2 版本開始,您可以使用grayscale_gamma_correction過濾器調整此伽瑪校正。您的過濾器必須返回一個浮點數,該浮點數將作為imagegammacorrect函數的outputgamma參數。

已知問題

當原圖大小小於指定的縮略圖大小時,不會生成灰階圖像。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Grayscale」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Sometimes, your website design requires to turn pictures in black & white : for example in a gallery display, you can have all thumbnails in grayscale and bring up colors when the mouse is hovering it.
This plugin will make it possible without the need to manualy create the grayscale variant of each picture.
In your theme’s functions.php, instead of using WP add_image_size function, use grayscale_add_image_size('custom_size', xxx, yyy, $crop, $grayscale) (with $crop set to true if you want to crop the image, and $grayscale set to true if you want a grayscale version of the image). Then, you can use the_post_thumbnail or any thumbnail function to get your grayscale image :
the_post_thumbnail('custom_size-gray')

A gamma correction is applied automatically to make the black & white pictures look good. From version 1.2, You can tune this gamma correction with the grayscale_gamma_correction filter. Your filter would have to return a float number that will be use as the outputgamma parameter of the imagegammacorrect function.
Known bugs

Grayscale images are not generated when the original image size is smaller than the specified thumbnail size.

延伸相關外掛

文章
Filter
Mastodon