
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.
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 '<a href="' . get_permalink($album_ID) . '">'; if ($album_thumbnail) { echo '<img src="' . $album_thumbnail[0] . '" alt />'; } echo '</a>'; } } 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 '<img src="' . $image_src[0] . '" alt />'; } } } 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(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php while (have_posts()) { the_post(); ?> <article class="hentry"> <header class="entry-header"> <?php the_title('<h1 class="entry-title">', '</h1>'); ?> </header> <div class="entry-content"> <?php $kt_Photogallery->render(); ?> </div> </article> <?php } ?> </main> </div> <?php get_footer(); 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.
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
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:
$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
Starting from $0 per month.
Rating
Reviewers
No reviews
Tags
Developed By
Daniel Menȝies
Quick & Easy
Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!
Testimonial plugins for Wordpress
Galleries plugins for Wordpress
SEO plugins for Wordpress
Contact Form plugins for Wordpress
Forms plugins for Wordpress
Social Feeds plugins for Wordpress
Social Sharing plugins for Wordpress
Events Calendar plugins for Wordpress
Sliders plugins for Wordpress
Analytics plugins for Wordpress
Reviews plugins for Wordpress
Comments plugins for Wordpress
Portfolio plugins for Wordpress
Maps plugins for Wordpress
Security plugins for Wordpress
Translation plugins for Wordpress
Ads plugins for Wordpress
Video Player plugins for Wordpress
Music Player plugins for Wordpress
Backup plugins for Wordpress
Privacy plugins for Wordpress
Optimize plugins for Wordpress
Chat plugins for Wordpress
Countdown plugins for Wordpress
Email Marketing plugins for Wordpress
Tabs plugins for Wordpress
Membership plugins for Wordpress
popup plugins for Wordpress
SiteMap plugins for Wordpress
Payment plugins for Wordpress
Coming Soon plugins for Wordpress
Ecommerce plugins for Wordpress
Customer Support plugins for Wordpress
Inventory plugins for Wordpress
Video Player plugins for Wordpress
Testimonials plugins for Wordpress
Tabs plugins for Wordpress
Social Sharing plugins for Wordpress
Social Feeds plugins for Wordpress
Slider plugins for Wordpress
Reviews plugins for Wordpress
Portfolio plugins for Wordpress
Membership plugins for Wordpress
Forms plugins for Wordpress
Events Calendar plugins for Wordpress
Contact plugins for Wordpress
Comments plugins for Wordpress
Analytics plugins for Wordpress
Common Ninja Apps
Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.
Display Bluesky posts with a Bluesky feed carousel that auto updates, shows posts in a clear layout, and keeps visitors engaged.
Add Messenger Chat to your site to communicate with visitors, offer fast support, and create a smoother user experience across all pages.
Add an MP3 Player to your website and engage visitors with music, podcasts, and spoken audio without any setup complexity.
Use a subscription button to streamline recurring payments, simplify signup, and help increase conversions with seamless PayPal or Stripe integration.
Add a unified chat tool to your site that connects users via WhatsApp, Messenger, Telegram, or email for seamless support.
Create interactive quizzes with a quiz maker that lets you build custom questions, collect responses, and increase engagement with easy site integration.
Present all your locations with a clear company branch list that helps customers find nearby offices, understand key details, and enjoy a smoother experience.
Use an order form to let customers submit product orders, save entries, receive notifications, and collect payments through PayPal or Stripe for a smoother buying experience.
Create immersive 360 virtual tours with interactive hotspots that let visitors explore spaces, view details clearly, and experience panoramic environments seamlessly.
Verify visitor age with an age verification popup that helps you meet legal requirements, protect your business, and ensure responsible access.
Create an interactive glossary that displays clear definitions, images, and search options to help visitors learn terms quickly and navigate complex topics with ease.
Transform PDFs into interactive flipbooks with a PDF flipbook widget that improves reading and keeps visitors engaged.
More plugins
The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!
