Forked from tomhemsley/Meta Slider - Easy Fancybox Integration
Last active
September 21, 2017 05:49
-
-
Save sukhikh18/7ec5fbee7c752f3cf243fcf98c361b47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* INSTALLATION: this code should be pasted into your theme's functions.php file. | |
* | |
* To Use: Install 'Easy Fancybox'. 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 | |
* | |
* @tested on WP - 4.4.11; Meta Slider - 3.5.1 | |
*/ | |
function metaslider_easy_fancybox($attributes, $slide, $slider_id) { | |
if (!strlen($attributes['href'])) { | |
$attributes['href'] = wp_get_attachment_url( get_post_meta( $slide['id'], '_thumbnail_id', true) ); | |
$attributes['class'] = 'fancybox'; | |
$attributes['rel'] = "gallery-{$slider_id}"; | |
} | |
return $attributes; | |
} | |
add_filter('metaslider_flex_slider_anchor_attributes', 'metaslider_easy_fancybox', 10, 3); | |
add_filter('metaslider_nivo_slider_anchor_attributes', 'metaslider_easy_fancybox', 10, 3); | |
add_filter('metaslider_responsive_slider_anchor_attributes', 'metaslider_easy_fancybox', 10, 3); | |
add_filter('metaslider_coin_slider_anchor_attributes', 'metaslider_easy_fancybox', 10, 3); | |
/* END metaslider /simple lightbox integration */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment