Want to skyrocket the popularity of your plugin and reach millions of eager users? Look no further than WP Hive. Gain credibility through in-depth reviews, drive conversions with targeted email marketing, and boost visibility with strategic social promotion and exposure
Sorry, pal! The plugin couldn’t pass all our tests. No hard feelings, right?
Tests done by WP Hive test script Results
Minimal impact on memory usage The memory usage of this plugin is less than the average memory usage of other plugins on WordPress.org + 200KB. Check FAQ for more.
Minimal impact on pagespeed The impact of this plugin on PageSpeed is less than the average impact of other plugins on WordPress.org + 1000 milliseconds
No PHP errors, warning, notices WP Hive automated test found no PHP error while activating this plugin on our server
No Javascript issues WP Hive automated test found no JavaScrip error while activating this plugin on our server
Latest PHP 7.2.16 compatible WP Hive automated test found the plugin fully compatible with the latest version of PHP
Latest WordPress 5.3.2 compatible WP Hive automated test found the plugin fully compatible with the latest version of WordPress
Optimized database footprint The plugin creates less than 50 database tables
No activation errors WP Hive automated test found no activation error while activating this plugin on our server
No resource errors WP Hive automated test found no resource error/s while trying this plugin on our server
Frequently updated The plugin was not updated at least once in the last 90 days
All the plugins are tested on the same server with exactly same configuration via test script that automatically activates and logs the data WP Hive shows.
All the scripts run on a VPS with 8 CPU cores and 8 GB of RAM.
The test sites are hosted on Google Cloud VM instances, one site/plugin per instance. The machine type is n1-standard-1. The server is a 8 core CPU with 8GB of RAM.
The test sites are hosted on Apache/2 server and they are tested on PHP 7.2.16 & WordPress 5.3.2.
The database server is MySQL 8.0.15 and the default PHP memory limit is 256MB.
Disclosure: When you buy through affiliate links on this site, WP Hive may earn a commission which we use to keep the site running. Learn more →
About Photogallery
Description
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....
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();
?>
', '');
?>
render();
?>
Language & Translation
This plugin is in English (en_US) by default but comes with a German (de_DE) po-file.
There is also a pot file containing untranslated strings so you can use it if you wish to translate this plugin.
See also Using Localizations.
And especially WordPress – Poedit: Translation Secrets.
If you want your translation included in the next version of Photogallery, don’t hesitate and let me know.
Get Poedit.
Open the the pot file with Poedit and translate it.
Save a copy as e.g kt-photogallery-fr_FR.po in /wp-content/plugins/kt-photogallery/language. The mo-file will be created automatically by Poedit if you ticked the checkbox in the preferences.
PHP API
I have included a number of functions for fetching album, image and thumbnail IDs associated with a gallery or album.
Please note that all methods starting with an underscore are considered internal and are not documented here. Although some are publicly accessible you should not use them directly unless you know what you are doing.
You do not have to create a new kt_Photogallery instance, there is already one in the global namespace.
Access all public methods via $kt_Photogallery.
$kt_Photogallery->get_album_count ( [$gallery_ID] )
Returns the number of albums associated with a gallery Argumentint|null $gallery_IDOptional – ID of a gallery. Defaults to the current ID if used inside the Loop Returnsinteger|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. Argumentint|null $gallery_IDOptional – ID of a gallery. Defaults to the current ID if used inside the Loop Returnsarray|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 Argumentint|null $album_IDOptional – ID of an album. Defaults to the current ID if used inside the Loop Returnsinteger|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. Argumentint|null $album_IDOptional – ID of an album. Defaults to the current ID if used inside the Loop Returnsarray|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 Argumentint|null $album_IDOptional – ID of an album. Defaults to the current ID if used inside the Loop Argumentboolean $fallbackOptional – if true and $album_ID yields no album the method returns the ID of the first image associated with the album. Default is true Returnsinteger|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. Argumentint|null $album_IDOptional – ID of an album. Defaults to the current ID if used inside the Loop Argumentboolean $fallbackOptional – if true and $album_ID yields no album the method returns the ID of the first image associated with the album. Default is true Returnsarray|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_gallery_design ( $key, $options )
Registers a custom design for albums and galleries respectively.
The design will be available in the Design metabox during editing Returnsboolean – returns true if the design was registered successfully, false on failure. Argumentstring $keyRequired – A key used as id inside HTML/CSS and for general identification Argumentcallable|array $optionsRequired – 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. Argumentboolean auto_designoptional – If set true and no design is found, take the first registered one and proceed. Default is true Returnsboolean – Returns true on success, false otherwise
Want to skyrocket the popularity of your plugin and reach millions of eager users? Look no further than WP Hive. Gain credibility through in-depth reviews, drive conversions with targeted email marketing, and boost visibility with strategic social promotion and exposure
Be Part of the Conversation with WordPress Enthusiasts
Using Photogallery? Great, join the conversation now!
Let’s talk about overall quality, ease of use, stellar support, unbeatable value, and the amazing experience Photogallery brings to you.