Thursday, 8 August 2013

How to copy numeric Fancybox v2 title to img alt value

How to copy numeric Fancybox v2 title to img alt value

Fancybox 2.
I am using for my images the special script for the numeric titles.
Is it any way to copy this title values as the img alt values?
HTML:
<p>Group 1.</p>
<a class="fancybox" rel="group1"
href="http://fancyapps.com/fancybox/demo/1_b.jpg"><img
src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt=""/></a>
<a class="fancybox" rel="group1"
href="http://fancyapps.com/fancybox/demo/2_b.jpg"><img
src="http://fancyapps.com/fancybox/demo/2_s.jpg" alt=""/></a>
<p>Group 2.</p>
<a class="fancybox" rel="group2"
href="http://fancyapps.com/fancybox/demo/3_b.jpg"><img
src="http://fancyapps.com/fancybox/demo/3_s.jpg" alt=""/></a>
<a class="fancybox" rel="group2"
href="http://fancyapps.com/fancybox/demo/4_b.jpg"><img
src="http://fancyapps.com/fancybox/demo/4_s.jpg" alt=""/></a>
<p>Single.</p>
<a class="fancybox" href="http://fancyapps.com/fancybox/demo/5_b.jpg"><img
src="http://fancyapps.com/fancybox/demo/5_s.jpg" alt=""/></a>
JavaScript:
$(document).ready(function() {
$(".fancybox").fancybox({
helpers : {
title : { type : 'inside' }
}, // helpers
beforeShow : function() {
this.title = (this.title ? '' + this.title + '<br />' : '') + 'Image '
+ (this.index + 1) + ' of ' + this.group.length;
} // beforeShow
}); // fancybox
}); // ready
Example: JSFIDDLE

No comments:

Post a Comment