前言介紹
- 這款 WordPress 外掛「Photogallery」是 2014-11-04 上架。
- 目前有 40 個安裝啟用數。
- 上一次更新是 2017-08-20,距離現在已有 2814 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.0 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
album | image | photo | gallery | picture |
內容簡介
這個外掛主要是為了主題開發人員而設計。
這個外掛允許從媒體管理器中收集照片並將它們排列成相簿。
這些相簿可以組成圖庫。
相簿和圖庫都可以添加到主題的導覽菜單中。
請注意,此外掛不提供任何用於前端展示相簿和圖庫的CSS格式和JavaScript。您需要自己格式化它們並整合必要的JavaScript函式庫,例如Lightbox。此外掛僅提供自訂文章類型的相簿和圖庫創建框架以及用於前端展示的設計註冊。
如果您發現錯誤或有任何問題、投訴或建議,請隨時與我聯繫。
主題整合
為了讓相簿或圖庫運作,您必須為主題撰寫自定義文章類型模板檔案。
這為主題開發人員提供了最多的控制權,而且也讓使用者透過WordPress儀表板方便地創建相簿。
如果您安裝此外掛,並創建相簿和圖庫,並將它們包含在您的主題菜單中,您會感到失望,因為什麼也不會發生。
在您的主題目錄中建立兩個php檔案:single-photogallery.php 和 single-photoalbum.php。
single-photogallery.php每次查看圖庫時都會被調用
single-photoalbum.php每次查看相簿時都會被調用
現在,您有兩個選擇:
您可以通過主題的function.php註冊自定義設計,例如 $kt_Photogallery->register_gallery_design(),並在您的single-photogallery.php中的合適位置調用$kt_Photogallery->render() 依據使用者的選擇渲染它。
您可以檢索相簿、圖片、縮略圖詳細信息,並為所有相簿和圖庫渲染一致的HTML。
請參閱PHP API部分以了解有關如何檢索相簿ID、圖片ID和縮略圖詳細信息的更多詳細信息。
例子
一個自定義圖庫設計的基本示例:
# functions.php
$kt_Photogallery->register_gallery_design ('my_gallery_design', array(
'label' => __('My Gallery Design', 'my-textdomain'),
'icon' => 'dashicons-format-gallery',
'title' => __('This is my custom gallery design', 'my-textdomain'),
'render' => 'render_my_gallery_design'
));
$kt_Photogallery->register_album_design ('my_album_design', array(
'label' => __('My Album Design', 'my-textdomain'),
'icon' => 'dashicons-format-image',
'title' => __('This is my custom album design', 'my-textdomain'),
'render' => 'render_my_album_design'
));
function render_my_gallery_design ($post) {
global $kt_Photogallery;
$album_IDs = $kt_Photogallery->get_albums($post);
if ($album_IDs) {
foreach ($album_IDs as $album_ID) {
$album_thumbnail = $kt_Photogallery->get_thumbnail_src($album_ID);
echo '';
if ($album_thumbnail) {
echo '';
}
echo '';
}
} else {
printf(__('The gallery %s does not contain any albums', 'my-textdomain'), esc_html($post->post_title));
}
}
function render_my_album_design ($post) {
global $kt_Photogallery;
$image_IDs = $kt_Photogallery->get_images($post);
if ($image_IDs) {
foreach ($image_IDs as $image_ID) {
$image_src = $kt_Photogallery->get_image_src($image_ID, 'large');
$image_title = get_the_title($image_ID);
echo '';
echo '';
echo '';
}
} else {
printf(__('The album %s does not contain any images', 'my-textdomain'), esc_html($post->post_title));
}
}
原文外掛簡介
This plugin is meant primarily for theme developers.
This plugin allows to collect photos from the the Media Manager and arrange them into albums.
These albums can be combined into galleries.
Both albums and galleries can be added to a theme’s navigation menu.
Note that this plugin does not provide any CSS formatting and JavaScript for frontend presentation of galleries and albums. You have to format them yourself and integrate necessary JavaScript libraries, e.g Lightbox, yourself. This plugin merely gives a framework for gallery and album creation via custom post types and registration of designs for a frontend presentation.
If you found a bug or have any questions, complains or suggestions please feel free to contact me.
Theme Integration
You have to write post type template files for your theme in order for an album or gallery to work.
This gives Theme developers the most control over a frontend presentation and users a convenient way to create galleries through the WordPress dashboard.
If you install this plugin, create albums and galleries and include them into your theme’s menu, you will be disappointed, since nothing will happen.
Create two php files inside your theme’s directory: single-photogallery.php and single-photoalbum.php.
single-photogallery.php gets called everytime a gallery is about to be viewed
single-photoalbum.php gets called everytime a album is about to be viewed
Now you have two options.
You can register a custom design inside your theme’s function.php via e.g $kt_Photogallery->register_gallery_design() and call $kt_Photogallery->render() at an appropriated place inside your single-photogallery.php to render it depending on the user’s choice.
You fetch albums, images and thumbnail details, and render consistent HTML for all albums and galleries.
Refere to the PHP API section for further details on how to retrieve album IDs, image IDs and thumbnail details.
Example
A basic example for a custom gallery design
# functions.php
$kt_Photogallery->register_gallery_design ('my_gallery_design', array(
'label' => __('My Gallery Design', 'my-textdomain'),
'icon' => 'dashicons-format-gallery',
'title' => __('This is my custom gallery design', 'my-textdomain'),
'render' => 'render_my_gallery_design'
));
$kt_Photogallery->register_album_design ('my_album_design', array(
'label' => __('My Album Design', 'my-textdomain'),
'icon' => 'dashicons-format-image',
'title' => __('This is my custom album design', 'my-textdomain'),
'render' => 'render_my_album_design'
));
function render_my_gallery_design ($post) {
global $kt_Photogallery;
$album_IDs = $kt_Photogallery->get_albums($post);
if ($album_IDs) {
foreach ($album_IDs as $album_ID) {
$album_thumbnail = $kt_Photogallery->get_thumbnail_src($album_ID);
echo '';
if ($album_thumbnail) {
echo '';
}
echo '';
}
} else {
printf(__('The gallery %s does not contain any albums', 'my-textdomain'), esc_html($post->post_title));
}
}
function render_my_album_design ($post) {
global $kt_Photogallery;
$image_IDs = $kt_Photogallery->get_images($post);
if ($image_IDs) {
foreach ($image_IDs as $image_ID) {
$image = get_post($image_ID);
if ($image) {
$image_src = wp_get_attachment_image_src($image_ID, 'medium');
if (!$image_src) {
$image_src = wp_get_attachment_image_src($image_ID, 'full');
}
echo '';
}
}
} else {
printf(__('The album %s does not contain any images', 'my-textdomain'), esc_html($post->post_title));
}
}
Basic integration into Twenty Fifteen:
# single-photogallery.php or single-photoalbum.php
get_header();
?>
');
?>
?>
get_album_count ( [$gallery_ID] )
Returns the number of albums associated with a gallery
Argument int|null $gallery_ID Optional – ID of a gallery. Defaults to the current ID if used inside the Loop
Returns integer|boolean – Returns an integer on success, or false if $gallery_ID yields no gallery
$kt_Photogallery->get_albums ( [$gallery_ID] )
Returns an array of album IDs associated with a gallery.
Argument int|null $gallery_ID Optional – ID of a gallery. Defaults to the current ID if used inside the Loop
Returns array|boolean – Returns an array of IDs on success, false if $gallery_ID yields no gallery
$kt_Photogallery->get_image_count ( [$album_ID] )
Returns the number of images associated with an album
Argument int|null $album_ID Optional – ID of an album. Defaults to the current ID if used inside the Loop
Returns integer|boolean – Returns an integer on success, or false if $album_ID yields no album
$kt_Photogallery->get_images ( [$album_ID] )
Returns an array of image IDs associated with an album.
Argument int|null $album_ID Optional – ID of an album. Defaults to the current ID if used inside the Loop
Returns array|boolean – Returns an array of IDs on success, false if $album_ID yields no album
$kt_Photogallery->get_thumbnail ( [$album_ID, [$fallback] ] )
Returns the ID of the image (attachment) used as thumbnail for an album
Argument int|null $album_ID Optional – ID of an album. Defaults to the current ID if used inside the Loop
Argument boolean $fallback Optional – if true and $album_ID yields no album the method returns the ID of the first image associated with the album. Default is true
Returns integer|false – Returns an integer on success, false if $album_ID yields no album, no thumbnail is set or a fallback could not been resolved
$kt_Photogallery->get_thumbnail_src ( [$album_ID, [$fallback] ] )
Returns an ordered array with values corresponding to the (0) url, (1) width, (2) height and (3) scale of the thumbnail associated with an album.
Argument int|null $album_ID Optional – ID of an album. Defaults to the current ID if used inside the Loop
Argument boolean $fallback Optional – if true and $album_ID yields no album the method returns the ID of the first image associated with the album. Default is true
Returns array|false – Returns an array on success, false if $album_ID yields no album, no thumbnail is set or a fallback could not been resolved
$kt_Photogallery->register_album_design ( $key, $options )
$kt_Photogallery->register_gallery_design ( $key, $options )
Registers a custom design for albums and galleries respectively.
The design will be available in the Design metabox during editing
Returns boolean – returns true if the design was registered successfully, false on failure.
Argument string $key Required – A key used as id inside HTML/CSS and for general identification
Argument callable|array $options Required – A callback rendering the design on the frontend or an associative array:
string label – The text for the label
string icon – The image shown next to the label. Can be dashicons-*, an URL to an image or a base 64 encoded image
string title – Text used inside the HTML title attribute, usually containing a description
callback render ($post, $options) – Callback rendering the design on the frontend. The arguments passed are the current post as a WP_Post instance and an associative array of the options straight from the database
callback options ($current_options, $defaults, $post) – Callback for additional form fields, should echo HTML. The arguments passed are an associative array of the options straight from the database, the default options as second argument and the current post as a WP_Post instance as third.
array defaults – Associative array containing default values for options. Its keys are used during saving so you should generate HTML form fields using its keys and provide a callback for filtering.
callback filter ($current_options, $defaults, $post) – Callback for filtering the options before they are saved. This callback is called every time a post is saved. The arguments passed are the default options merged with the values from the current request, the default options as second argument and the current post as a WP_Post instance as third. The callback must return an associative array otherwise no options are stored.
$kt_Photogallery->render( [$auto_design] )
Main output method. Depending on the current post type the method prints out a design for a gallery or an album.
Argument boolean auto_design optional – If set true and no design is found, take the first registered one and proceed. Default is true
Returns boolean – Returns true on success, false otherwise
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Photogallery」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.9 | 1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.0.1 | 1.2.1 | trunk |
延伸相關外掛(你可能也想知道)
Slider, Gallery, and Carousel by MetaSlider – Image Slider, Video Slider 》使用MetaSlider,您可以在數分鐘內創建強大的、優化的幻燈片、輪播、橫向滑屏或相冊,它是全球#1的響應式WordPress幻燈片外掛。MetaSlider是圖像、照片、視...。
Photo Gallery, Sliders, Proofing and Themes – NextGEN Gallery 》WordPress圖庫插件, 自2007年以來,NextGEN Gallery已成為行業標準的WordPress圖庫插件,每年繼續接收超過150萬的新下載量。它很容易管理簡單的照片圖庫,但...。
Photo Gallery by 10Web – Mobile-Friendly Image Gallery 》委員會翻譯如下:, , Photo Gallery 是建立美麗的行動裝置友好型相簿所需的領導外掛程式,只需幾分鐘即可完成。, 有用的連結:, 現場示範, 10Web 的高級 Phot...。
Firelight Lightbox 》Easy FancyBox WordPress外掛為您的網站提供靈活美觀的光箱解決方案,幾乎適用於網站上的所有媒體連結。Easy FancyBox使用更新的傳統FancyBox jQuery擴展版本...。
Simple Lightbox 》Simple Lightbox 是一個非常簡單且可自定義的燈箱,在您的 WordPress 網站上添加它非常容易。, 功能, 自定義燈箱行為的選項位於外觀 > Lightbox 管理員菜...。
Responsive Lightbox & Gallery 》提供完整的 WordPress 相簿外掛所需一切, Responsive Lightbox and Gallery 外掛是一個全功能的 WordPress 相簿外掛,擁有強大的拖放相簿生成器和 Lightbox ...。
FooGallery – Responsive Photo Gallery, Image Viewer, Justified, Masonry & Carousel 》lugin/show-more-pagination/" rel="nofollow ugc">demo, Supports webP image compression for faster page loads, Advanced caching techniques for faster...。
Lightbox & Modal Popup WordPress Plugin – FooBox 》FooBox是第一個嚴肅考慮響應式佈局的燈箱。它不僅會將圖片縮放以在手機上呈現更好的效果,還會重新排列按鈕控制,使其在縱向或橫向的方向上都展現出色的外觀...。
Gallery Plugin for WordPress – Envira Photo Gallery 》相片集外掛, , 有用連結:, , 相片集範例, 相片集文件, 相片集支援, , 我們認為你不應該必須聘請開發人員來建立 WordPress 相片集。這就是為什麼我們建立了 E...。
WP Show Posts 》注意事項, 此外掛目前僅收到安全性更新。請查看我們的GenerateBlocks外掛以獲得更現代的解決方案。, , , WP Show Posts能夠透過易於使用的簡碼在您網站上的任...。
Carousel, Slider, Gallery by WP Carousel – Image Carousel with Lightbox & Photo Gallery, Video Slider, Post Carousel & Post Grid, Product Carousel & Product Grid 》, 實時演示 | 影片教程 | 使用說明 | 升級至專業版 », 概觀, WP Carousel 是最強大且使用者友好的 WordPress 公告欄外掛,可建立帶圖片、文章、WooComm...。
Visual Portfolio, Photo Gallery & Post Grid 》WordPress 的圖庫和作品集外掛, ★★★★★, 作品集網站是當今最受歡迎的網站之一。我們創建了Visual Portfolio,Photo Gallery和Post Grid WordPress外掛程式,這...。
ACF Photo Gallery Field 》t; 'Status', , 'name' => 'status', , 'choices' => array(, 'public' => 'Public', , 'private' => ...。
WP Featherlight – A Simple jQuery Lightbox 》WP Featherlight 是一個 WordPress 外掛,可為您的WordPress 網站添加一個極簡、高效、響應式 jQuery 燈箱。在其核心,WP Featherlight是一個用於 Featherlig...。
Premium Portfolio Features for Phlox theme 》概述, 這個外掛為 Phlox 主題增加許多高級作品集功能,讓您能以優雅的方式展示和呈現您的專案。, , Phlox 主題的演示 | 文件 | 視頻教程 | 支援論壇, , 功能...。