[WordPress] 外掛分享: Flickr API

首頁外掛目錄 › Flickr API
20+
安裝啟用
★★☆☆☆
2.5/5 分(2 則評價)
4255 天前
最後更新
問題解決
WordPress 3.0+ v0.1.9 上架:2011-10-13

內容簡介

這個 Flickr API 外掛程式提供工具,讓您可以使用簡碼在文章和頁面中顯示您的 Flickr 相簿、集、相片串流或收藏等,或者作為小工具使用。您可以選擇所需的圖像大小,是否要將其連結到另一個圖像大小或回到 Flickr,或者完全不連結,還可以決定要顯示多少圖像,以及更多的選項...

此外插件還內建了一些選項,可以讓您選擇要將圖像顯示為簡單的幻燈片或使用 Galleria jquery 外掛。或者,您也可以選擇樣式化輸出,並使用自己的 JavaScript。

對於開發人員,此外掛還提供了一種在 PHP 和 JavaScript 中調用和快取 API 響應的簡單方法,並且提供了許多有用的工具來處理這些響應。

用法

您需要從 Flickr 獲取 API 金鑰才能使用此外掛。在「您」菜單下尋找「您的應用程式」。點擊獲取金鑰,然後轉到媒體設置畫面,添加您的 API 金鑰和使用者名稱。該外掛會自動確定您的 NSID,因此您無需自己查找。

要使用外掛,請使用媒體上傳/插入按鈕生成簡碼,然後選擇要取得的項目,或使用提供的 Flickr 小工具。

面向開發人員

此外掛公開其方法供主題使用,但您可能會發現最有用的是 flickr_api()。這是一個通用函數,用於調用指定參數的任何 API 方法。

<?php
$response = json_decode( flickr_api( $method, $params, $cache ) );
?>

所有響應均以 JSON 格式提供,因此您需要使用 json_decode() 在 PHP 中使用響應。

@param $method: (string) 要調用的 API 方法
@param $params: (array) 要傳遞到呼叫中的其他參數,如 user_id、photoset_id、gallery_id、text、tags 等
@param $cache : (bool) 是否根據傳遞的參數來快取響應

您也可以使用 JavaScript 來通過 API:

<script>
var photos = flickr_api( method, params, cache );
</script>

NSID 查詢:

<?php
$nsid = flickr_get_user_nsid( $username );
?>

只需傳遞 Flickr 使用者名稱即可獲取 NSID。

過濾器/Hooks

flickr_galleria_themes

您可以通過擴展主題數組,啟用自訂或已購買的 galleria 主題選擇。如果您希望您的主題除了「經典」樣式外還有選擇 galleria 主題的選擇,這非常有用。

<?php
add_filter( 'flickr_galleria_themes', 'my_galleria_themes' );
function my_galleria_themes( $themes ) {
$themes[ /* 完整或相對 URL 到主題 JS 檔案 */ ] = __( '主題名稱' );
return $themes;
}
?>

外掛標籤

開發者團隊

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

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

原文外掛簡介

The Flickr API plugin provides tools for displaying your flickr galleries, sets, photostream or favourites and more using a shortcode in posts and pages or as a widget. You can choose the size of image you want, whether it should be linked to another image size or back to flickr or not linked at all, how many images to show and more…
There are some built in options for displaying your images as a simple slideshow or using the Galleria jquery plugin. Alternatively you can choose to style the output yourself and use your own javascript.
For developers the plugin also gives you an easy method for calling and caching API responses both in PHP and javascript, and lots of useful tools for working with those responses.
Usage
You will need to get an API key from flickr to use this plugin. Under the ‘You’ menu look for ‘Your Apps’. Click to get a key and then go to the media settings screen to add your API key and user name. The plugin will automatically determine your NSID so you never need to look this up.
To use the plugin either generate a shortcode using the media upload/insert button and selecting what you want to get or use the Flickr widget provided.
For developers
The plugin exposes its methods for your use in themes as template tags but the main one you may find useful is flickr_api(). This is a general function for calling any API method with the parameters you specify.

All responses are in JSON format so you will need to use json_decode() to use the response in PHP.
@param $method: (string) This is the API method to call
@param $params: (array) Additional arguments to pass into the call such as user_id, photoset_id, gallery_id, text, tags etc...
@param $cache : (bool) Whether or not to cache the response based on the arguments passed in

You can use the API via javascript as well:

NSID lookup:

Just pass in the Flickr username of the person to get the NSID for.
Filters/Hooks
flickr_galleria_themes
You can enable the choice of custom or purchased galleria themes by extending the themes array. Useful if you want your theme to have a choice of galleria theme beyond the ‘classic’ style.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon