Advertisement
Guest User

Untitled

a guest
Jan 17th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <?php
  2. function gc_get_images($size = 'large', $limit = '0', $offset = '0') {
  3. global $post;
  4.  
  5. $images = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
  6.  
  7. if ($images) {
  8.  
  9. $num_of_images = count($images);
  10.  
  11. if ($offset > 0) : $start = $offset--; else : $start = 0; endif;
  12. if ($limit > 0) : $stop = $limit+$start; else : $stop = $num_of_images; endif;
  13.  
  14. $i = 0;
  15. foreach ($images as $image) {
  16. if ($start <= $i and $i < $stop) {
  17. $img_title = $image->post_title; // title.
  18. $img_description = $image->post_content; // description.
  19. $img_caption = $image->post_excerpt; // caption.
  20. $img_url = wp_get_attachment_url($image->ID); // url of the full size image.
  21. $preview_array = image_downsize( $image->ID, $size );
  22. $img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
  23.  
  24.  
  25. ?>
  26.  
  27. <li><img src="<?php echo $img_preview; ?>" alt="<?php echo $img_caption; ?>" /><p class="caption"><?php echo $img_caption; ?></p></li>
  28.  
  29. <?
  30.  
  31. }
  32. $i++;
  33. }
  34.  
  35. }
  36. }
  37. ?>
  38.  
  39. <!-- HTML -->
  40. <div class="slider">
  41. <ul class="slides">
  42. <?php gc_get_images('large','0','0'); ?>
  43. </ul>
  44. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement