zeshanshani
1/6/2016 - 7:25 AM

Envira Gallery - Load Lightbox from Link

Envira Gallery - Load Lightbox from Link

<!--
1. Change data-envira-gallery-id to the Gallery ID you want to display
2. Ensure that Gallery is on the same page as the below link
3. Ensure the PHP file above is located in wp-content/plugins and activated via WordPress Admin > Plugins
-->
<a href="#" class="envirabox" data-envira-gallery-id="1234">Load Gallery in Lightbox</a>
<?php
/**
* Plugin Name: Envira Gallery - Load Lightbox from Link
* Plugin URI: http://enviragallery.com
* Version: 1.0
* Author: Tim Carr
* Author URI: http://www.n7studios.co.uk
* Description: Launch a gallery's lightbox from a link. Requires that the gallery be embedded into the Page.
*/

function envira_gallery_launch_lightbox( $data ) {

	?>
	<script>
		jQuery(document).ready(function($) {
			$('.envirabox').on('click', function(e) {
				e.preventDefault();
				$('.envira-gallery-'+$(this).data('envira-gallery-id')).envirabox().click();
			});
		});
	</script>
	<?php

}
add_filter( 'wp_footer', 'envira_gallery_launch_lightbox' );