image.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php get_header(); ?>
  2. <div class="wrapper section-inner">
  3. <div class="content left">
  4. <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  5. <div class="posts">
  6. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  7. <div class="content-inner">
  8. <div class="featured-media">
  9. <?php $imageArray = wp_get_attachment_image_src($post->ID, 'full', false); ?>
  10. <a href="<?php echo esc_url( $imageArray[0] ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment">
  11. <?php echo wp_get_attachment_image( $post->ID, 'post-image' ); ?></a>
  12. </div> <!-- /featured-media -->
  13. <div class="post-header">
  14. <h2 class="post-title"><?php echo basename(get_attached_file( $post->ID )); ?></h2>
  15. <div class="post-meta">
  16. <span><?php echo the_time(get_option('date_format')); ?></span>
  17. <span class="date-sep"> / </span>
  18. <span><?php echo $imageArray[1] // 1 is the width ?> <span style="text-transform:lowercase;">x</span> <?php echo $imageArray[2] . ' px'; // 2 is the height ?></span>
  19. </div>
  20. </div> <!-- /post-header -->
  21. <?php if ( ! empty( $post->post_excerpt ) ) : ?>
  22. <div class="post-content">
  23. <?php the_excerpt(); ?>
  24. </div> <!-- /post-content -->
  25. <?php endif; ?>
  26. </div> <!-- /content-inner -->
  27. <div class="post-meta-bottom">
  28. <div class="post-nav">
  29. <?php
  30. /**
  31. * Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
  32. * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
  33. */
  34. $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
  35. foreach ( $attachments as $k => $attachment ) :
  36. if ( $attachment->ID == $post->ID )
  37. break;
  38. endforeach;
  39. $l = $k - 1;
  40. $k++;
  41. if ( isset( $attachments[ $k ] ) ) :
  42. // get the URL of the next image attachment
  43. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  44. $prev_attachment_url = get_attachment_link( $attachments[ $l ]->ID );
  45. else :
  46. // or get the URL of the first image attachment
  47. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  48. endif;
  49. ?>
  50. <a href="<?php echo esc_url( $prev_attachment_url ); ?>" class="post-nav-older" rel="attachment"><?php _e('&laquo; Previous<span> attachment</span>', 'hemingway'); ?></a>
  51. <a href="<?php echo esc_url( $next_attachment_url ); ?>" class="post-nav-newer" rel="attachment"><?php _e('Next<span> attachment</span> &raquo;', 'hemingway'); ?></a>
  52. <div class="clear"></div>
  53. </div> <!-- /post-nav -->
  54. </div> <!-- /post-meta-bottom -->
  55. <?php comments_template( '', true ); ?>
  56. <?php endwhile; else: ?>
  57. <p><?php _e("We couldn't find any posts that matched your query. Please try again.", "hemingway"); ?></p>
  58. <?php endif; ?>
  59. </div> <!-- /post -->
  60. </div> <!-- /posts -->
  61. </div> <!-- /content -->
  62. <?php get_sidebar(); ?>
  63. <div class="clear"></div>
  64. </div> <!-- /wrapper section-inner -->
  65. <?php get_footer(); ?>