I’m trying to use title and “captions” from image alt tags with fancybox 2… for some reason I can’t seem this to work…
$('.fancybox').fancybox({
beforeShow : function() {
this.title = '<div class="new-title-title">' + $(this).attr('title') + '</div><div class="new-title-alt">' + $(this).children('img:first').attr('alt') + '</div>';
},
helpers : {
title: {
type: 'inner',
beforeShow: function(opts) {
console.log('beforeShow title helper');
},
},
},
});
Titles from $(this).attr(‘title’) work, Captions from $(this).children(‘img:first’).attr(‘alt’) say undefined… I know I must be missing something simple…
If I understood right, you want fancybox title as a combination of the
titleattribute in theatag + thealtattribute in theimgtag.If the above is correct, then having a html like
the fancybox title should say “title anchor 01 alt image 01“
you do that with this script: