Featherlight 图像计数 Index/Total [索引错误]

Featherlight Image Count Index/Total [Indexing Error]

我正在尝试在 Featherlight Gallery 中添加图像数。 示例:图片 1,共 6 张(某处 beside/below 一张图片)

$.featherlightGallery.prototype.afterContent = function(){
    var object = this.$instance,
        target = this.$currentTarget,
        parent = target.parent(),
        caption = parent.find('.wp-caption-text'),
        galParent = target.parents('.gallery-item'),
        jetParent = target.parents('.tiled-gallery-item');

    $('<div class="count">Image ' + (currentNavigation() + 1)+' of ' + slides().length + '</div>').html(object.find('.featherlight-content'));

    if (0 !== galParent.length) {
        caption = galParent.find('.wp-caption-text');
    } else if (0 !== jetParent.length) {
        caption = jetParent.find('.tiled-gallery-caption');
    }
    object.find('.caption').remove();
    if (0 !== caption.length) {
        $('<div class="caption">').text(caption.text()).appendTo(object.find('.featherlight-content'));
    }
}

它让我返回错误:currentNavigation is not defined

您需要致电this.currentNavigation()

天哪!我知道了!我想这是a幸!在尝试了一些概率之后,这就是最终答案。我希望有人会觉得这很有用 ;D

$.featherlightGallery.prototype.afterContent = function(){
    var object = this.$instance,
        target = this.$currentTarget,
        parent = target.parent(),
        caption = parent.find('.wp-caption-text'),
        galParent = target.parents('.gallery-item'),
        jetParent = target.parents('.tiled-gallery-item');

    var sc = $('<div class="count">Image ' + (this.currentNavigation() + 1) + ' of ' + this.slides().length + '</div>');
    sc.appendTo(object.find('.featherlight-content'));

    object.find('.count').remove();
    if (0 !== sc.length) {
        sc.appendTo(object.find('.featherlight-content'));
    }
    if (0 !== galParent.length) {
        caption = galParent.find('.wp-caption-text');
    } else if (0 !== jetParent.length) {
        caption = jetParent.find('.tiled-gallery-caption');
    }
    object.find('.caption').remove();
    if (0 !== caption.length) {
        $('<div class="caption">').text(caption.text()).appendTo(object.find('.featherlight-content'));
    }
}