Betiok
9/18/2017 - 10:32 AM

lightGallery

<?php if ($loop ->have_posts()): while ($loop->have_posts()) : $loop->the_post(); ?>
		<?php
			$image_full = get_the_post_thumbnail_url($loop->ID, 'full');
			$image_thumb = get_the_post_thumbnail_url($loop->ID, 'custom-small-1');
		?>

		<article id="post-<?php the_ID(); ?>" <?php post_class('col'); ?>>
			<a href="<?php echo $image_full; ?>">
				<img src="<?php echo $image_thumb; ?>" alt="">
			</a>
		</article>
<?php endwhile; ?>

<?php endif; ?>
function initGallery() {
    $('.lightgallery').lightGallery({
        selector: '.col a',
        counter: false,
        download: false,
        controls: false
    });
}

initGallery();

$('body').on('click', '.lightgallery .col a', function(ev){
    setTimeout(init_slider, 10);

    function init_slider() {
        $('.lg-sub-html .carousel').on('init', function(event, slick, currentSlide, nextSlide){
            var slides = slick.slideCount;

            if(slides == 1) {
                $(this).addClass('single-slide');
            }
        });

        $('.lg-sub-html .carousel').slick({
            slidesToShow: 1,
            slidesToScroll: 1,
            variableWidth: true,
            infinite: false,
            responsive: [
                {
                    breakpoint: 800,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                        variableWidth: false,
                    }
                }
            ]
        });
    }
});
if (is_page_template('template-gallery.php')) {
	wp_register_script('lightgallery', get_stylesheet_directory_uri() . '/js/lightgallery.min.js', array('jquery'), '1.6.1');
	wp_enqueue_script('lightgallery');
	
	wp_register_style('lightgallerycss', get_template_directory_uri() . '/css/lightgallery.css', array(), '1.6.1', 'all');
	wp_enqueue_style('lightgallerycss');

	wp_register_script('lginit', get_stylesheet_directory_uri() . '/js/lginit.js', array('jquery'), '1.0.0');
	wp_enqueue_script('lginit');
}