CCDzine
10/17/2015 - 11:00 PM

Add Fancybox to images link to media file, separate single images from galleries. This goes before the closing body tag and presumes that Fa

Add Fancybox to images link to media file, separate single images from galleries. This goes before the closing body tag and presumes that Fancybox is enqueued.

jQuery(document).ready(function() {
	jQuery( "a[href$='.jpg'], a[href$='.jpeg'], a[href$='.png'], a[href$='.gif']" ).fancybox({
		openEffect : 'elastic'
	});
});

// Images inside <div class="gallery"> as in WordPress
jQuery(document).ready(function() {
	jQuery( ".gallery a[href$='.jpg'], .gallery a[href$='.jpeg'], .gallery a[href$='.png'], .gallery a[href$='.gif']" ).attr( 'rel', 'gallery' ).fancybox({
		openEffect : 'elastic'
	});
});

Fancybox Image Links