Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tomhemsley
Created July 29, 2014 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhemsley/60e94d5a29f34968bbd3 to your computer and use it in GitHub Desktop.
Save tomhemsley/60e94d5a29f34968bbd3 to your computer and use it in GitHub Desktop.
Meta Slider - WP Lightbox 2 Integration
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* To Use: Install 'WP Lightbox 2'. Leave the URL blank on an image slide in Meta Slider.
* The slide will automatically be linked to it's full image in a lightbox
*/
function metaslider_wp_lightbox_2($attributes, $slide, $slider_id) {
if (!strlen($attributes['href'])) {
$attributes['href'] = wp_get_attachment_url($slide['id']);
$attributes['rel'] = "lightbox[{$slider_id}]";
}
return $attributes;
}
add_filter('metaslider_flex_slider_anchor_attributes', 'metaslider_wp_lightbox_2', 10, 3);
add_filter('metaslider_nivo_slider_anchor_attributes', 'metaslider_wp_lightbox_2', 10, 3);
add_filter('metaslider_responsive_slider_anchor_attributes', 'metaslider_wp_lightbox_2', 10, 3);
add_filter('metaslider_coin_slider_anchor_attributes', 'metaslider_wp_lightbox_2', 10, 3);
/* END metaslider / WP Lightbox 2 integration */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment