将图像alt用于Fancybox标题 [英] Use image alt for Fancybox captions

查看:92
本文介绍了将图像alt用于Fancybox标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用图片的标题或'alt'属性作为FancyBox的标题出现。以下是相关代码:

I am trying to use the title or 'alt' attribute of images to come up as titles with FancyBox. Here is the relevant code:

$("a[rel=fancybox]").fancybox({
        'transitionIn'      : 'fade',
        'transitionOut'     : 'elastic',
        'titlePosition'     : 'inside',
        'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Look ' +
                          (currentIndex + 1) + ' / ' + currentArray.length + 
                           (title.length ? ' &nbsp; ' + title : '') + '</span>';
        },
        'autoScale':false,
        'mouseWheelNavigation':   false, 
        'onComplete' : function() {$("#fancybox-wrap").unbind('mousewheel.fb');} ,
    });
});


推荐答案

在我看来,你正在使用fancybox v1。 3.4,不是吗?。

It seems to me that you are using fancybox v1.3.4, aren't you?.

了解fancybox的标题在该版本中的工作原理查看此帖子

To learn how fancybox's titles work in that version check this post.

设置fancybox标题您的缩略图的alt 属性,使用API​​选项 titleFromAlt 。您可以从这篇文章了解如何使用它

To set the fancybox title from the alt attribute of your thumbnail, use the API option titleFromAlt. You can learn how to use it from this post

这篇关于将图像alt用于Fancybox标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆