• Resolved echappee06

    (@echappee06)


    Hello,
    I would like to display a carousel with a lightbox on clic.
    I use the premium theme Flatsome and I would like to use the theme lightbox (called magnificPopup). It is part of the theme and not a plugin, so how can I do to use the Metaslider Lightbow with the lightbox that comes with the theme, and not with one of the compatible plugins ?
    Kind regards.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi @echappee06,

    You wont need this lightbox plugin to get that working. You will have to add the necessary classes to MetaSlider more directly. Do you have any programming experience? You will have to add a filter to add the classes to MetaSlider in the appropriate areas depending on the requirements of Magnific Popup.

    Here are the relevant filters:
    metaslider_flex_slider_image_attributes
    metaslider_flex_slider_anchor_attributes
    metaslider_css_classes

    Let me know if you have any questions

    Thread Starter echappee06

    (@echappee06)

    Hi !
    I have limited experience in programming but I will try to do it with these filters, according to the documentation.
    Thanks !

    Let me know what you come up with and if you get stuck somewhere I can take a look.

    Thread Starter echappee06

    (@echappee06)

    Should I still use the Meta Slider Lightbox plugin ?
    I have this error message because no lightbox plugin is used and so I cannot check the lightbox checkbox : “Warning: MetaSlider Lightbox is installed but no supported lightbox plugin is active. ”

    I added this in my functions.php :

    function metaslider_add_full_url_to_slides($attributes, $slide, $slider_id) {
    if (!strlen($attributes[‘href’])) {
    $attributes[‘href’] = wp_get_attachment_url($slide[‘id’]);
    }
    return $attributes;
    }
    add_filter(‘metaslider_flex_slider_anchor_attributes’, ‘metaslider_add_full_url_to_slides’, 10, 3);

    function metaslider_add_rel_attribute_to_images($attributes, $slide, $slider_id) {
    $attributes[‘rel’] = ‘lightbox’;
    return $attributes;
    }
    add_filter(‘metaslider_flex_slider_image_attributes’, ‘metaslider_add_rel_attribute_to_images’, 10, 3);

    but no link is added to my images. The rel attribute works fine though.

    Hey @echappee06,

    No, you should disable the plugin. The filters you used would apply anyway but you will get that error message if a required plugin isn’t installed.

    Thread Starter echappee06

    (@echappee06)

    OK, thanks !
    So I just have an issue with this filter which doesn’t work :

    function metaslider_add_full_url_to_slides($attributes, $slide, $slider_id) {
    	if (!strlen($attributes['href'])) {
    		$attributes['href'] = wp_get_attachment_url($slide['id']);
    	}
    	return $attributes;
    }
    add_filter('metaslider_flex_slider_anchor_attributes', 'metaslider_add_full_url_to_slides', 10, 3);

    Do you have any idea to help me make it work ?

    Hi @echappee06

    What are you expecting that filter to do? Do you have a URL to the slideshow so I can see whats happening instead?

    Thread Starter echappee06

    (@echappee06)

    I would like to add a link to the slides so the lightbox could work.
    I can send you a link in a private message if you want.

    Thread Starter echappee06

    (@echappee06)

    I finally made it work with this code :

    function metaslider_add_full_url_to_slides($attributes, $slide, $slider_id) {
    
    	$thumbnail_id = ('attachment' === get_post_type($slide['id'])) ? $slide['id'] : get_post_thumbnail_id($slide['id']);
    
    	if (empty($attributes['href'])) {
    		$attributes['href'] = wp_get_attachment_url($thumbnail_id);
    		$attributes['class'] = 'lightbox-gallery';
    	}
    	return $attributes;
    }
    add_filter('metaslider_flex_slider_anchor_attributes', 'metaslider_add_full_url_to_slides', 10, 3);

    Hope this will help somebody !

    Hi @echappee06,

    Looks good. One thing you likely don’t need is that check for the post type. It’s in the MetaSlider code for backwards compatibility but hasn’t been used for a couple of years.

    I’ll mark this as resolved. Please open a new issue if you have any more questions.

    If you’re enjoying MetaSlider please leave us a 5-star review. They really help let others find our plugin more easily. If you don’t think we deserve the 5 stars please let us know how we can improve, too.

    https://www.ads-software.com/support/plugin/ml-slider/reviews#new-post

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Use with premium theme’ is closed to new replies.