在已经运行的lightGallery实例中添加/编辑选项

是否可以在已经运行的lightGallery脚本实例中添加/编辑选项? 我有这个WordPress主题,它在画廊上加载lightGallery实例,我需要添加/编辑其某些选项(例如:更改图像之间的过渡效果),而无需修改主主题文件(例如,在子主题上)

这是在主题中找到的代码:

var container = $( '.gallery' );
var parseImage = container.data( 'images' );

if ( typeof $.fn.lightGallery != 'undefined' ) {
    container.lightGallery({
        dynamic : true,dynamicEl : parseImage
    });
}

可以做到吗?

预先感谢

yanchengwanghao 回答:在已经运行的lightGallery实例中添加/编辑选项

从他们的Pluging API page

    // You can access all lightgallery variables and functions like this.
    this.core = $(element).data('lightGallery');

    this.$el = $(element);
    this.core.s = $.extend({},defaults,this.core.s)

似乎s的{​​{1}}属性包含所有选项。因此,您可以在那里设置模式。像这样:

$(element).data('lightGallery')

我在他们的过渡演示页面上的控制台中对此进行了测试,并且确实可以正常工作。

本文链接:https://www.f2er.com/2745399.html

大家都在问