content-image.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  2. <div class="primary col-18 last">
  3. <div class="entry-content">
  4. <div class="entry-attachment">
  5. <div class="attachment">
  6. <?php
  7. /**
  8. * 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,
  9. * 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
  10. */
  11. $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' ) ) );
  12. foreach ( $attachments as $k => $attachment ) {
  13. if ( $attachment->ID == $post->ID )
  14. break;
  15. }
  16. $k++;
  17. // If there is more than 1 attachment in a gallery
  18. if ( count( $attachments ) > 1 ) {
  19. if ( isset( $attachments[ $k ] ) )
  20. // get the URL of the next image attachment
  21. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  22. else
  23. // or get the URL of the first image attachment
  24. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  25. } else {
  26. // or, if there's only 1 image, get the URL of the image
  27. $next_attachment_url = wp_get_attachment_url();
  28. }
  29. $image_src = wp_get_attachment_image_src( $post->ID, 'full' );
  30. ?>
  31. <a class="fancyimg" href="<?php echo $image_src[0]; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
  32. $attachment_size = apply_filters( 'foto_attachment_size', array( 1200, 1200 ) ); // Filterable image size.
  33. echo wp_get_attachment_image( $post->ID, $attachment_size );
  34. ?></a>
  35. </div><!-- .attachment -->
  36. <?php if ( ! empty( $post->post_excerpt ) ) : ?>
  37. <div class="entry-caption">
  38. <?php the_excerpt(); ?>
  39. </div>
  40. <?php endif; ?>
  41. </div><!-- .entry-attachment -->
  42. <?php the_content(); ?>
  43. <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'foto' ), 'after' => '</div>' ) ); ?>
  44. </div><!-- .entry-content -->
  45. <?php comments_template(); ?>
  46. </div><!-- end .primary -->
  47. <aside class="secondary col-6">
  48. <div class="entry-meta">
  49. <div class="content-heading"><?php _e('Image Information', 'foto'); ?></div>
  50. <ul class="content-data">
  51. <!-- Meta image
  52. Credit: Responsive Theme by Emil -->
  53. <?php $foto_data = get_post_meta($post->ID, '_wp_attachment_metadata', true); ?>
  54. <li class="full-size">
  55. <span class="data-left"><?php _e('Full Size','foto'); ?></span>
  56. <span class="separator">:</span>
  57. <span class="data-right"><a class="fancyimg" href="<?php echo wp_get_attachment_url($post->ID); ?>"><?php echo $foto_data['width'] . '&#215;' . $foto_data['height']; ?></a> px</span>
  58. </li>
  59. <?php if ($foto_data['image_meta']['aperture']) { ?>
  60. <li class="aperture">
  61. <span class="data-left"><?php _e('Aperture','foto'); ?></span>
  62. <span class="separator">:</span>
  63. <span class="data-right">f/<?php echo $foto_data['image_meta']['aperture']; ?></span>
  64. </li>
  65. <?php } ?>
  66. <?php if ($foto_data['image_meta']['focal_length']) { ?>
  67. <li class="focal-length">
  68. <span class="data-left"><?php _e('Focal Length','foto'); ?></span>
  69. <span class="separator">:</span>
  70. <span class="data-right"><?php echo $foto_data['image_meta']['focal_length']; ?><?php _e('mm','foto'); ?></span>
  71. </li>
  72. <?php } ?>
  73. <?php if ($foto_data['image_meta']['iso']) { ?>
  74. <li class="iso">
  75. <span class="data-left"><?php _e('ISO','foto'); ?></span>
  76. <span class="separator">:</span>
  77. <span class="data-right"><?php echo $foto_data['image_meta']['iso']; ?></span>
  78. </li>
  79. <?php } ?>
  80. <?php if ($foto_data['image_meta']['shutter_speed']) { ?>
  81. <li class="shutter">
  82. <span class="data-left"><?php _e('Shutter','foto'); ?></span>
  83. <span class="separator">:</span>
  84. <span class="data-right"><?php
  85. if ((1 / $foto_data['image_meta']['shutter_speed']) > 1) {
  86. echo "1/";
  87. if (number_format((1 / $foto_data['image_meta']['shutter_speed']), 1) == number_format((1 / $foto_data['image_meta']['shutter_speed']), 0)) {
  88. echo number_format((1 / $foto_data['image_meta']['shutter_speed']), 0, '.', '') . ' sec';
  89. } else {
  90. echo number_format((1 / $foto_data['image_meta']['shutter_speed']), 1, '.', '') . ' sec';
  91. }
  92. } else {
  93. echo $foto_data['image_meta']['shutter_speed'] . ' sec';
  94. }
  95. ?></span>
  96. </li>
  97. <?php } ?>
  98. <?php if ($foto_data['image_meta']['camera']) { ?>
  99. <li class="camera">
  100. <span class="data-left"><?php _e('Camera:','foto'); ?></span>
  101. <span class="separator">:</span>
  102. <span class="data-right"><?php echo $foto_data['image_meta']['camera']; ?></span>
  103. </li>
  104. <?php } ?>
  105. </ul>
  106. </div><!-- end entry-meta -->
  107. <?php do_action( 'foto_after_entry_meta' ); ?>
  108. </aside><!-- end .secondary -->
  109. <nav class="site-navigation image-navigation" role="navigation">
  110. <span class="previous-image"><?php previous_image_link( false, __( '&larr; Previous', 'foto' ) ); ?></span>
  111. <span class="next-image"><?php next_image_link( false, __( 'Next &rarr;', 'foto' ) ); ?></span>
  112. </nav><!-- .image-navigation -->
  113. </article><!-- #post-<?php the_ID(); ?> -->