tareq1988

WPUF Show Attachment Images

May 11th, 2012
416
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $attachments = wpfu_get_attachments( $post->ID );
  3.  
  4. if ( $attachments ) {
  5.     $attach = '<ul class="wpuf-attachments">';
  6.  
  7.     foreach ($attachments as $file) {
  8.  
  9.         //if the attachment is image, show the image. else show the link
  10.         if ( wpuf_is_file_image( $file['url'], $file['mime'] ) ) {
  11.             $thumb = wp_get_attachment_image_src( $file['id'] );
  12.             $attach .= sprintf( '<li><a href="%s"><img src="%s" alt="%s" /></a></li>', $file['url'], $thumb[0], esc_attr( $file['title'] ) );
  13.         } else {
  14.             $attach .= sprintf( '<li><a href="%s" title="%s">%s</a></li>', $file['url'], esc_attr( $file['title'] ), $file['title'] );
  15.         }
  16.     }
  17.  
  18.     $attach .= '</ul>';
  19.    
  20.     echo $attach;
  21. }
RAW Paste Data