Advertisement
martawijaya

Untitled

Apr 10th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.64 KB | None | 0 0
  1. <script>
  2. var $pswp2 = $('.pswp')[0];
  3.       $('.gallery-section').each(function() {
  4.         var $pic2     = $(this),
  5.         getItems2 = function() {
  6.           var items2 = [];
  7.           $pic2.find('a.gallery-popup').each(function() {
  8.             var $href2   = $(this).attr('href'),
  9.             $size2   = $(this).data('size').split('x'),
  10.             $width2  = $size2[0],
  11.             $height2 = $size2[1];
  12.  
  13.             var item2 = {
  14.               src : $href2,
  15.               w   : $width2,
  16.               h   : $height2
  17.             };
  18.  
  19.             items2.push(item2);
  20.           });
  21.           return items2;
  22.         };
  23.  
  24.         var items2 = getItems2();
  25.  
  26.         $pic2.find('a.gallery-popup').click( function(event) {
  27.           event.preventDefault();
  28.           var $index2 = $(this).data('index');
  29.           var options2 = {
  30.             index: $index2,
  31.             bgOpacity: 0.7,
  32.             showHideOpacity: true
  33.           };
  34.  
  35.               // Initialize PhotoSwipe
  36.               var lightBox2 = new PhotoSwipe($pswp2, PhotoSwipeUI_Default, items2, options2);
  37.               lightBox2.init();
  38.             });
  39.       });
  40. </script>
  41.  
  42. <div class="gallery-section">
  43.       <?php
  44.           $galleries = get_field('gallery_images');
  45.          $imgfirst = wp_get_attachment_image_src( $galleries['images'][0], 'full' );
  46.          $full_image_sizes = $imgfirst[1].'x'.$imgfirst[2];
  47.      ?>
  48.       <a href="<?php echo $imgfirst[0]; ?>" data-src="<?php echo $imgfirst[0]; ?>" data-size="<?php echo $full_image_sizes; ?>" data-index="0" class="gallery-popup">
  49.         <img class="full-gallery" src="<?php echo $imgfirst[0] ?>">
  50.       </a>
  51. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement