
內容簡介
Image Widget 是一個簡單的外掛程式,利用 WordPress 原生媒體管理員,為您的網站新增圖片小工具。
需要新增幻燈片、燈箱或隨機圖像嗎?
請查看 Image Widget Plus!
Image Widget 的功能
回應式
MU 相容
處理圖片變更大小及對齊
連結圖片
新增標題及描述
多功能 - 所有欄位都是可選的
上傳、連結至外部圖像或從您的媒體集選擇圖像
使用篩選器勾子或主題覆寫自訂外觀與樣式
更多功能與Image Widget Plus一同提供
可信任的品質
Image Widget由 The Events Calendar 開發和維護,他們也是The Events Calendar, Event Tickets以及全套精選的外掛程式開發團隊。
我們的團隊會積極支援這個外掛程式,另外也會接受社群成員的貢獻,如果您在論壇看見可以幫助的問題,或者有很好的主意可以編碼並提交補丁程式,這是很好的!
Image Widget Plus!
Image Widget Plus功能包括:
多圖像支援
隨機圖像
幻燈片
燈箱
立即查看Image Widget Plus!
Pull Requests &Translations
在GitHub上查看以獲得拉取更新的更改。
翻譯可以提交此處於 WordPress.org 上。
文件
內建的範本可以被置於您的樣本中的檔案覆寫。
預設與自訂範本
Image Widget附有用於小工具輸出的預設範本。如果您想要修改小工具顯示程式碼,請在您的樣板目錄中建立一個名為“image-widget”的新資料夾,並複製“views / widget.php”文件。
您可以隨心所欲地編輯新檔案。請不要編輯外掛程式資料夾中的文件,因為當您升級到最新版本時,這會導致衝突。
3.2新增: 現在您還可以使用“sp_template_image-widget_widget.php”篩選器來將.php模板檔的預設範本行為覆寫。例如:如果您想要widget.php留在名為my-custom-templates /的資料夾中,並想要它被稱為my-custom-name.php:
add_filter('sp_template_image-widget_widget.php', 'my_template_filter');
function my_template_filter($template) {
return get_template_directory() . '/my-custom-templates/my-custom-name.php';
}
篩選器
有許多篩選器可供在程式碼中覆寫數據。了解哪些篩選器是可用的最好的方法始終是通過簡單搜索代碼使用“apply_filters”。但是,這裡是一些更基本的篩選器:
widget_title
這實際上是小工具中的一個相當典型的篩選器,用於將篩選器套用於小工具標題。
widget_text
這是另一個非常典型的小工具篩選器,用於將篩選器套用於描述正文文字。此篩選器還接受
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
Image Widget is a simple plugin that uses the native WordPress media manager to add image widgets to your site.
Image Widget Features
Responsive
MU Compatible
Handles image resizing and alignment
Link the image
Add title and description
Versatile – all fields are optional
Upload, link to external image, or select an image from your media collection
Customize the look & feel with filter hooks or theme overrides
Quality You Can Trust
Image Widget is developed and maintained by The Events Calendar, the same folks behind The Events Calendar, Event Tickets, and a full suite of premium plugins.
This plugin is actively supported by our team and contributions from community members. If you see a question in the forum you can help with or have a great idea and want to code it up or submit a patch, that would be awesome! Not only will we shower you with praise and thanks, it’s also a good way to get to know us and lead into options for paid work if you freelance.
Pull Requests & Translations
Check us out on GitHub to pull request changes.
Translations can be submitted here on WordPress.org.
Documentation
The built in template can be overridden by files within your template.
Default vs. Custom Templates
The Image Widget comes with a default template for the widget output. If you would like to alter the widget display code, create a new folder called “image-widget” in your template directory and copy over the “views/widget.php” file.
Edit the new file to your hearts content. Please do not edit the one in the plugin folder as that will cause conflicts when you update the plugin to the latest release.
New in 3.2: You may now also use the “sp_template_image-widget_widget.php” filter to override the default template behavior for .php template files. Eg: if you wanted widget.php to reside in a folder called my-custom-templates/ and wanted it to be called my-custom-name.php:
add_filter('sp_template_image-widget_widget.php', 'my_template_filter');
function my_template_filter($template) {
return get_template_directory() . '/my-custom-templates/my-custom-name.php';
}
Filters
There are a number of filters in the code that will allow you to override data as you see fit. The best way to learn what filters are available is always by simply searching the code for ‘apply_filters’. But all the same, here are a few of the more essential filters:
widget_title
This is actually a pretty typical filter in widgets and is applied to the widget title.
widget_text
Another very typical widget filter that is applied to the description body text. This filter also takes 2 additional arguments for $args and $instance so that you can learn more about the specific widget instance in the process of filtering the content.
image_widget_image_attachment_id
Filters the attachment id of the image.
Accepts additional $args and $instance arguments.
image_widget_image_url
Filters the url of the image displayed in the widget.
Accepts additional $args and $instance arguments.
THIS IS DEPRECATED AND WILL EVENTUALLY BE DELETED
image_widget_image_width
Filters the display width of the image.
Accepts additional $args and $instance arguments.
image_widget_image_height
Filters the display height of the image.
Accepts additional $args and $instance arguments.
image_widget_image_maxwidth
Filters the inline max-width style of the image. Hint: override this to use this in responsive designs 🙂
Accepts additional $args and $instance arguments.
Return null to remove this css from the image output (defaults to ‘100%’).
image_widget_image_maxheight
Filters the inline max-height style of the image.
Accepts additional $args and $instance arguments.
Return null to remove this css from the image output (defaults to null)
image_widget_image_size
Filters the selected image ‘size’ corresponding to WordPress registered sizes.
If this is set to ‘tribe_image_widget_custom’ then the width and height are used instead.
Accepts additional $args and $instance arguments.
image_widget_image_align
Filters the display alignment of the image.
Accepts additional $args and $instance arguments.
image_widget_image_alt
Filters the alt text of the image.
Accepts additional $args and $instance arguments.
image_widget_image_link
Filters the url that the image links to.
Accepts additional $args and $instance arguments.
image_widget_image_link_target
Filters the link target of the image link.
Accepts additional $args and $instance arguments.
image_widget_image_attributes
Filters a list of image attributes used in the image output. Similar to ‘wp_get_attachment_image_attributes’
Accepts $instance arguments
image_widget_link_attributes
Filters a list of attributes used in the image link. Similar to ‘wp_get_attachment_image_attributes’
Accepts $instance arguments
Have You Supported the Image Widget?
If so, then THANK YOU! Also, feel free to add this line to your wp-config.php file to prevent the image widget from displaying a message after upgrades.
define( ‘I_HAVE_SUPPORTED_THE_IMAGE_WIDGET’, true );
For more info on the philosophy here, check out our blog post
