Posted By

shin on 09/28/12


Tagged

wordpress images wp


Versions (?)

show attachment images (except for the first image) with description (user thumbnail size)


 / Published in: PHP
 

description from title, image size from function.php (addimagesize( 'descr', 278, 200, true );)

  1. <?php
  2. $images = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 1000, 'offset'=>1));
  3. if ( empty($images) ) {
  4.  
  5. } else {
  6. echo '<ul class="descr-phot">';
  7. foreach ( $images as $attachment_id => $attachment ) {
  8. echo '<li>';
  9. $large_image_url = wp_get_attachment_image_src( $attachment_id, 'full');
  10. $thumb = wp_get_attachment_image_src( $attachment_id, 'descr');
  11. echo '<a href="' . $large_image_url[0] . '" class="thickbox">';
  12. echo '<img src="'. $thumb[0]. '" />';
  13. echo '</a>';
  14. echo '<span>'. $attachment->post_title .'</span>';
  15. echo '</li>';
  16. }
  17. echo '</ul>';
  18. }
  19. ?>

Report this snippet  

You need to login to post a comment.