
Hi, I found a way of adding the lighbox attribute to WP galleries by using this code.
// Adds lightbox to gallery links
add_filter('wp_get_attachment_link', 'rc_add_rel_attribute');
function rc_add_rel_attribute($link) {
global $post;
return str_replace('<a href', '<a data-uk-lightbox="" href', $link);
}
Hope this helps!

Hei Keith
Thanks for the code! I pasted
beans_add_attribute('beans_post_gallery_icon', 'data-uk-lightbox', '{group:\'gallery\'}');
and your code into the functions.php file. Opened up a post and added 3 images into a gallery and then selected to have them link to the media file. Then tested the post. The lightbox did not work. So that would mean something is likely missing....
Btw I am working on figuring out how to get the regular lightbox and now this gallery lightbox to work, and will create a tutorial out of it that I can add to https://wpbeansframework.com/

You don't need the second bit of code only the code I posted. If it still isn't working then make sure the UIkit lightbox is being added.
function example_enqueue_uikit_assets() {
// Add lightbox.
beans_uikit_enqueue_components( 'lightbox', 'add-ons' );
}
The code goes in functions btw.

That is great Keith! I got it working..:)
A summary of the code used added into the functions.php file:
add_action( 'beans_uikit_enqueue_scripts', 'example_enqueue_uikit_assets' );
function example_enqueue_uikit_assets() {
// Add lightbox.
beans_uikit_enqueue_components( 'lightbox', 'add-ons' );
}
// Adds lightbox to gallery links
add_filter('wp_get_attachment_link', 'rc_add_rel_attribute');
function rc_add_rel_attribute($link) {
global $post;
return str_replace('<a href', '<a data-uk-lightbox="" href', $link);
}
Do you know how to.... How would I go about customizing the animation when the lightbox opens? How would I show the caption in the lightbox?
--
How would I add a lightbox to regular images inside a post or page?
Hopefully your able to answer. It would be great to finally get these things working! Thanks again Keith!