[WordPress] 外掛分享: WP-Auto Image Grabber

首頁外掛目錄 › WP-Auto Image Grabber
20+
安裝啟用
尚無評分
5498 天前
最後更新
問題解決
WordPress 2.6+ v0.3.1 上架:2010-10-30

內容簡介

插入一個連結至某個網頁的圖片於部落格文章開始位置。一個簡單的演算法會試著取得「主題內容」的圖片(而不是廣告),並自動提供相關屬性的圖片,為文章增添意義。這特別對於將文章轉發至 Facebook 或 Digg 等網站的部落客非常有用,這些網站會使用文章中的第一幅圖片作為縮圖。

此外掛需要 PHP 5,使用 PHP 4 的網站會造成嚴重錯誤。

預設情況下,此掛件會依據您部落格文章中的第一個連結與該連結中預期適當的主題內容圖片。如果您的文章遵循特定的結構或模式,您可以透過設定 Pointer element for destination page 欄位來告訴掛件要遵循某個連結(例如某個特定 class 的連結)。

例如,以下 XPath 查詢會匹配第一個 grab-me class 連結:

//a[@class="grab-me"][1]

以下 XPath 查詢會匹配您的文章中最後一段裡的第一個連結:

//p[position()=last()]/a[1]

如需更多 XPath(以及 XQuery)語法範例,請參考 W3C 的 XPath 規格。如果您是一名開發人員,您也可以找到幾個XPath 工具會很有幫助。

此外,此掛件允許您在 <img> 元素上設置自訂的 class 值,只要在 Image class value 欄位中設置即可。為了確保最大的相容性,建議使用大多數佈景主題都會使用的 WordPress 產生的 class 之一。例如,使用 alignright 將會讓自動加入的圖片靠右對齊。
此掛件使用 PHP5 的 DOMDocument 方法來解析您的文章以及遠端網頁。它使用 XPath 來查詢 DOM。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.3.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「WP-Auto Image Grabber」→ 直接安裝(推薦)

原文外掛簡介

Inserts an image from a page you link to at the start of your blog post. A simple algorithm tries to get a “main content” image (rather than an advertisement), automatically providing your post with relevant, attributed artwork. This is especially useful for bloggers who syndicate posts to sites like Facebook or Digg, which use the first image in a post as a thumbnail for their post.
This plugin requires PHP 5; sites running on PHP 4 will produce fatal errors.
By default, the plugin will follow the first link in your blog post and grab what it thinks is an appropriate main content image from there. If your posts follow a particular structure or pattern, you can tell the plugin to follow a certain link (such as a link with a particular class) by setting the Pointer element for destination page value to an XPath query that returns the link you want.
For instance, the following XPath query will match the first link with a class of grab-me:
//a[@class="grab-me"][1]

Here’s an XPath query that will match the first link within the very last paragraph of your post:
//p[position()=last()]/a[1]

For more XPath (and XQuery) syntax examples, refer to the XPath specification at the W3C. If you’re a developer, you may also find several XPath tools helpful.
Additionally, this plugin allows you to set a custom class value on the element that it adds to your post by specifying it in the Image class value setting. For maximum compatibility, consider using one of the WordPress-generated classes most themes utilize. For instance, using alignright will probably make the automatically-added image float to the right.
This plugin uses PHP5’s DOMDocument methods to parse both your post and the remote page. It uses XPath to query the DOM.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon