Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. <?php
  2. global $woo_options;
  3. global $post;
  4. $use_timthumb = false; // Set to false to disable for this section of theme. Images will be downsized instead of resized to 640px width
  5. $repeat = 20; // Number of maximum attachments to get
  6. $photo_size = 'large'; // The WP "size" to use for the large image
  7. $thumb_size = 'thumbnail'; // The WP "size" to use for the thumbnail
  8. $thumb_width = 160; // Size of thumbnails
  9. $thumb_height = 160;
  10.  
  11. $width_setting = 534;
  12.  
  13. $id = $post->ID;
  14. $attachments = get_children( array(
  15. 'post_parent' => $id,
  16. 'numberposts' => $repeat,
  17. 'post_type' => 'attachment',
  18. 'post_mime_type' => 'image',
  19. 'order' => 'DESC',
  20. 'orderby' => 'menu_order date')
  21. );
  22.  
  23. // This is the custom code where we strip out all the images that are listed in custom meta fields.
  24. // 2011-01-05.
  25.  
  26. $image_meta_fields = array( 'image', '_wp_post_thumbnail' );
  27.  
  28. $image_meta_fields = apply_filters( 'woo_nongallery_fields', $image_meta_fields );
  29.  
  30. $attachments = woo_remove_meta_from_array( $attachments, $image_meta_fields );
  31.  
  32. if ( !empty($attachments) ) :
  33. $counter = 0;
  34. $photo_output = '';
  35. $thumb_output = '';
  36. foreach ( $attachments as $att_id => $attachment ) {
  37. $counter++;
  38.  
  39. /* Set the position of all non-first slides to "out of the view", while loading.
  40. This gets overridden by loopedSlider when the gallery is fully loaded.
  41. This is to prevent other images with longer heights than the first, from displaying
  42. underneath the first while the gallery is loading. */
  43.  
  44. $style = '';
  45.  
  46. $position_setting = $width_setting + 6;
  47.  
  48. if ( $counter == 1 ) {} else {
  49.  
  50. $style = ' style="position: absolute; left: -' . $position_setting . 'px;"';
  51.  
  52. } // End IF Statement
  53.  
  54. // Caption text
  55. /*
  56. $caption = "";
  57. if ($attachment->post_excerpt)
  58. $caption = '<span class="photo-caption">'.$attachment->post_excerpt.'</span>';
  59. */
  60.  
  61. // Save large photo
  62. $src = wp_get_attachment_image_src($att_id, $photo_size, true);
  63.  
  64. if ( ( get_option('woo_resize') == "true" && $use_timthumb == "true" ) || ( $src[1] > 540 ) )
  65. $photo_output .= '<div>'.woo_image('src=' . $src[0] . '&key=image&width=' . $width_setting . '&link=img&return=false&alt=' . $caption . '&class=single-photo').'</div>';
  66. else
  67. $photo_output .= '<div' . $style . '><a href="'. $src[0] .'" rel="lightbox[portfolio]" title="'.$attachment->post_excerpt.'"><img src="'. $src[0] .'" class="single-photo" alt="'.$attachment->post_excerpt.'" /></a>'.$caption.'</div>';
  68.  
  69. // Save thumbnail
  70. $src = wp_get_attachment_image_src($att_id, $thumb_size, true);
  71. $thumb_output .= '<li><a href="#"><img src="'. $src[0] .'" height="'.$thumb_height.'" width="'.$thumb_width.'" class="single-thumb" alt="'.$attachment->post_excerpt.'" />' . "</a></li>\n";
  72. }
  73. endif; ?>
  74.  
  75. <!-- Start Photo Slider -->
  76. <?php
  77. if ($counter == 1) {
  78. ?><div id="single-gallery-image"><?php
  79. echo $photo_output; // This will show the large photo in the slider
  80. ?></div><?php
  81. } else {
  82. ?>
  83.  
  84. <div id="slides" class="gallery sidebar">
  85. <div class="slides_container">
  86. <?php echo $photo_output; // This will show the large photo in the slider ?>
  87. </div>
  88.  
  89. <?php if ($counter > 1) : ?>
  90.  
  91. <div class="fix"></div>
  92.  
  93. <ul class="pagination">
  94. <?php echo $thumb_output; // This will show the thumbs ?>
  95. </ul>
  96. <?php endif; ?>
  97.  
  98. <div class="fix"></div>
  99. </div>
  100. <?php $counter_limit = 4; ?>
  101. <?php if ($counter < $counter_limit) { ?>
  102. <style type="text/css">
  103.  
  104. .jcarousel-prev { display:none!important; }
  105. .jcarousel-next { display:none!important; }
  106.  
  107. </style>
  108. <?php } ?>
  109. <?php } ?>
  110. <!-- End Photo Slider -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement