I’d like to know how I can add more than a title (e.g a caption or a link) to the fancybox.
I am aware that if I add a title=”Bla” it’ll show up in the box. But if I add something like caption=”Blabla” to my image link, what code do I need to have in jquery.fancybox.js to pull that caption tag?
I’d like to know how I can add more than a title (e.g a
Share
You don’t need to mess with original jquery.fancybox.js file since you could add this option within your own customized fancybox script.
If you are using
HTML5 DOCTYPE, you could use thedata-*attribute for you caption so you can have this HTML :Then set your custom fancybox script and get the
data-captionusing thebeforeShowcallback likeThat will override the
titleand use thedata-captioninstead.On the other hand, you may want to keep the
titleattribute and build the fancybox’stitlecombining both,titleanddata-captionattributes so, for this HTMLUse this script
Additionally, you could also get the
caption/titlefrom another HTML element within your document (a<div>for instance) that can have links or other HTML elements. Check these posts for code examples: https://stackoverflow.com/a/9611664/1055987 and https://stackoverflow.com/a/8425900/1055987NOTE : this is for fancybox v2.0.6+