/modules/minileven/theme/pub/minileven/image.php

  1. <?php 
  2. /** 
  3. * The template for displaying image attachments. 
  4. * 
  5. * @package Minileven 
  6. */ 
  7.  
  8. get_header(); ?> 
  9.  
  10. <div id="primary" class="image-attachment"> 
  11. <div id="content" role="main"> 
  12.  
  13. <?php while ( have_posts() ) : the_post(); ?> 
  14.  
  15. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
  16. <header class="entry-header"> 
  17. <h1 class="entry-title"><?php the_title(); ?></h1> 
  18. </header><!-- .entry-header --> 
  19.  
  20. <div class="entry-content"> 
  21.  
  22. <div class="entry-attachment"> 
  23. <div class="attachment"> 
  24. <?php 
  25. /** 
  26. * 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,  
  27. * 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 
  28. */ 
  29. $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' ) ) ); 
  30. foreach ( $attachments as $k => $attachment ) { 
  31. if ( $attachment->ID == $post->ID ) 
  32. break; 
  33. $k++; 
  34. // If there is more than 1 attachment in a gallery 
  35. if ( count( $attachments ) > 1 ) { 
  36. if ( isset( $attachments[ $k ] ) ) 
  37. // get the URL of the next image attachment 
  38. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 
  39. else 
  40. // or get the URL of the first image attachment 
  41. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID ); 
  42. } else { 
  43. // or, if there's only 1 image, get the URL of the image 
  44. $next_attachment_url = wp_get_attachment_url(); 
  45. ?> 
  46. <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php 
  47.  
  48. /** 
  49. * Filter the Mobile Theme image size. 
  50. * 
  51. * @module minileven 
  52. * 
  53. * @since 1.8.0 
  54. * 
  55. * @param int Image size in pixels. 
  56. */ 
  57. $attachment_size = apply_filters( 'minileven_attachment_size', 848 ); 
  58. echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height. 
  59. ?></a> 
  60.  
  61. <?php if ( ! empty( $post->post_excerpt ) ) : ?> 
  62. <div class="entry-caption"> 
  63. <?php the_excerpt(); ?> 
  64. </div> 
  65. <?php endif; ?> 
  66. </div><!-- .attachment --> 
  67.  
  68. </div><!-- .entry-attachment --> 
  69.  
  70. <div class="entry-description"> 
  71. <?php the_content(); ?> 
  72. <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'jetpack' ) . '</span>', 'after' => '</div>' ) ); ?> 
  73. </div><!-- .entry-description --> 
  74.  
  75. </div><!-- .entry-content --> 
  76.  
  77. <footer class="entry-meta"> 
  78. <div class="attachment-meta"> 
  79. <?php 
  80. $metadata = wp_get_attachment_metadata(); 
  81. printf( __( '<span class="entry-gallery">« <a href="%1$s" title="Back to %2$s" rel="gallery">Back to Gallery</a></span>', 'jetpack' ),  
  82. esc_url( get_permalink( $post->post_parent ) ),  
  83. get_the_title( $post->post_parent ) 
  84. ); 
  85. ?> 
  86. </div><!-- .attachment-meta--> 
  87. <?php if ( comments_open() ) : ?> 
  88. <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'jetpack' ) . '</span>', __( '<b>1</b> Reply', 'jetpack' ), __( '<b>%</b> Replies', 'jetpack' ) ); ?></span> 
  89. <?php endif; // End if comments_open() ?> 
  90. <?php edit_post_link( __( 'Edit', 'jetpack' ), '<span class="edit-link">', '</span>' ); ?> 
  91. </footer><!-- #entry-meta --> 
  92. </article><!-- #post-<?php the_ID(); ?> --> 
  93.  
  94. <nav id="nav-single"> 
  95. <h3 class="assistive-text"><?php _ex( 'Image navigation', 'next-saturday' , 'jetpack' ); ?></h3> 
  96. <span class="nav-previous"><?php previous_image_link( false, __( '« Previous' , 'jetpack' ) ); ?></span> 
  97. <span class="nav-next"><?php next_image_link( false, __( 'Next » ' , 'jetpack' ) ); ?></span> 
  98. </nav><!-- #nav-single --> 
  99.  
  100. <?php comments_template(); ?> 
  101.  
  102. <?php endwhile; // end of the loop. ?> 
  103.  
  104. </div><!-- #content --> 
  105. </div><!-- #primary --> 
  106. <?php get_footer(); ?> 
.