batfan
5/1/2014 - 11:05 PM

Automatically Add Lightbox Class

Automatically Add Lightbox Class

$('div.entry-content a img').each(function() {
	// The href of the link	
	var theImageLink = $(this).parent("a").attr("href");
	// The link itself
	var theParent = $(this).parent("a");

	// Test the link to see if it's actually an image
	if ( !/\.(jpg|jpeg|gif|png)$/i.test(theImageLink) ) {
			// This isn't an image link, follow the href 
		} else {
			$(theParent).addClass('lbimage');
	}
});