Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?php if(have_rows( 'image_gallery' ) ): ?>
  2. <?php while(have_rows( 'image_gallery' ) ): the_row();
  3. $gallery_name = get_sub_field('gallery_name');
  4. $category_name = get_sub_field('category_name');
  5. $gallery = get_sub_field('image_gallery');
  6. $value = get_row_index();
  7. ?>
  8. <div class="gallery" id="selector<?php echo $value; ?>">
  9. <img src="<?php echo $gallery[0]['url']; ?>" alt="" class="gallery-photo">
  10. <div class="gallery-info">
  11. <a href="#" class="linkgallery"><?php echo $gallery_name; ?></a>
  12. </div>
  13. <div class="gallery-info gallery-category">
  14. <?php echo $category_name; ?>
  15. </div>
  16. </div>
  17. <?php endwhile; ?>
  18. <?php endif; ?>
  19.  
  20. $('#selector').on('click', function() {
  21.  
  22. $(this).lightGallery({
  23. dynamic: true,
  24. dynamicEl: [{
  25. "src": '../static/img/1.jpg',
  26. 'thumb': '../static/img/thumb-1.jpg',
  27. 'subHtml': '<h4>Fading Light</h4><p>Classic view from Rigwood Jetty on Coniston Water an old archive shot similar to an old post but a little later on.</p>'
  28. }, {
  29. 'src': '../static/img/2.jpg',
  30. 'thumb': '../static/img/thumb-2.jpg',
  31. 'subHtml': "<h4>Bowness Bay</h4><p>A beautiful Sunrise this morning taken En-route to Keswick not one as planned but I'm extremely happy I was passing the right place at the right time....</p>"
  32. }, {
  33. 'src': '../static/img/3.jpg',
  34. 'thumb': '../static/img/thumb-3.jpg',
  35. 'subHtml': "<h4>Coniston Calmness</h4><p>Beautiful morning</p>"
  36. }]
  37. })
  38.  
  39. });
  40.  
  41. var arrayFromPhp = <?php echo json_encode($gallery); ?>;
  42. var myArr = [];
  43. jQuery.each(arrayFromPhp, function(index, item) {
  44. myArr.push({"src": item.url, 'thumb': item.url});
  45. console.log(item.ID);
  46. });
  47.  
  48. $(this).lightGallery({
  49. dynamic: true,
  50. dynamicEl: myArr
  51. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement