Welcome to the Gallery Image Captions (GIC) demo page.
Title: Rocco at Campuhan Ridge
Caption: Our beloved Rocco
Description: Rocco enjoying another perfect day on the Campuhan Ridge.
Download
Title: Portrait of Chewbacca
Caption: Chewbacca "Chewie" poses for a portrait.
Description: Chewie back at our home in Payogan. Chewie is the philosopher of the family.
Download
Title: Beautiful Hope
Caption: Hope cantik/beautiful after an unbelievable transfurmation.
Description: Just a few months before this photo, Hope was in such bad shape that she wasn't recognizable as a dog.
Download
Title: Adorable Millie
Caption: Sweet Millie, our cancer survivor.
Description: You can see where the fur on her front leg was shaved for her latest round of chemo.
Download
The gallery above uses the Gallery Image Captions (GIC) plugin.
Usage
- Install and activate GIC.
- Write your GIC filter. See the filter example at the end of this page.
- Add your GIC filter to your child theme’s functions.php file.
- Write your GIC shortcode and add it to your page or post.
Using Gutenberg
This page is built with the Gutenberg block editor. The GIC shortcode that makes the gallery possible is inside a Gutenberg Shortcode block. Here’s the exact shortcode used for this page.
Not using Gutenberg?
You can also place the GIC shortcode in your page builder using a text element or inside the visual or text tab of the classical editor. Just make sure the shortcode is on one line by itself.
How do I find the Image IDs?
Beginning with version 1.2.0, GIC automatically adds an image ID column in your WordPress Media Library. This is to help you with adding the image IDs to your GIC shortcodes.
How GIC Works with Themes
I designed GIC as an alternative/replacement for the Avada theme gallery because of Avada’s shortcomings with image captions. So, please use GIC as a standalone solution.
GIC not meant to work inside or to enhance a page builder gallery element. It won’t add image captions to another gallery. It’s basically a supercharged version of WordPress’ original gallery shortcode.
GIC Filter
Here’s the exact PHP filter hook used for this demo.
<?php
/**
* Custom Filter for Gallery Image Captions
*
* Note: Avoid altering captiontag, selector, and itemtag.
*/
function mlc_gallery_image_caption($attachment_id, $captiontag, $selector, $itemtag) {
$id = $attachment_id;
// Grab the meta from the GIC plugin.
$my_image_meta = galimgcaps_get_image_meta($id);
/**
* Here's where to customise the caption content.
*
* This example uses the meta title, caption, description,
* and link to the media file.
*
* You can display any value from the $my_image_meta array.
* You can add your own HTML too.
*/
return "<{$captiontag} class='wp-caption-text gallery-caption' id='{$selector}-{$id}'>" .
"<strong>Title</strong>: " . $my_image_meta['title'] . "<br>" .
"<strong>Caption</strong>: " . $my_image_meta['caption'] . "<br>" .
"<strong>Description</strong>: ". $my_image_meta['description'] . "<br>" .
"<a href='" . $my_image_meta['src'] . "'>Download</a>" .
"</{$captiontag}></{$itemtag}>";
}
add_filter('galimgcaps_gallery_image_caption', 'mlc_gallery_image_caption', 10, 4);
Get the Plugin
Get the GIC plugin on WordPress.org.
Visit the GitHub repo and fork your own copy.