Hi,
I thought I’d share some information relevant to this topic with the hope that it would help someone out. I am using the wp-video-lightbox plugin with metaslider (flexslider).
Everything discussed so far has been to add the rel attribute to all slides. I needed only a specific slide to contain the rel attribute. To remedy this, I added the following to functions.php:
Add rel attribute to the slide that has a particular image
add_filter ('metaslider_image_slide_attributes', 'metaslider_lightbox', 10, 3);
function metaslider_lightbox($slide, $slider_id, $settings) {
if ($slide['src'] == "link/to/slide/image.png")
{
$slide['rel'] = "wp-video-lightbox";
}
return $slide;
}
Copy the rel attribute from slide image to slide anchor
add_filter('metaslider_flex_slider_anchor_attributes', 'link_slide_ref_and_a_ref', 10, 3);
function link_slide_ref_and_a_ref($anchor_attributes, $slide, $slider_id) {
$anchor_attributes['rel'] = $slide['rel'];
return $anchor_attributes;
}
Structure-wise, in Flexslider (and possibly the others), the slide image is nested under the slide link/anchor. As shown, I selected the slide image with the correct image url and added the rel attribute. Of course, this doesn’t do anything with the wp-lightbox-plugin, because the plugin requires the link/anchor to have this attribute for the lightbox effect to work. Therefore, in the second code block, I copied the rel attribute from the slide to the anchor.
I’m not too familiar with PHP so if there is a better way, feel free to share here. Thanks!