|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * The template for displaying image attachments. |
| 4 | + * |
| 5 | + * Learn more: http://codex.wordpress.org/Template_Hierarchy |
| 6 | + * |
| 7 | + * @package MITlib_Child |
| 8 | + * @since 1.0.0 |
| 9 | + */ |
| 10 | + |
| 11 | +namespace Mitlib\Child; |
| 12 | + |
| 13 | +get_header(); ?> |
| 14 | + <?php get_template_part( 'inc/breadcrumbs' ); ?> |
| 15 | + |
| 16 | + <div id="stage" class="inner" role="main"> |
| 17 | + |
| 18 | + <?php get_template_part( 'inc/title-banner' ); ?> |
| 19 | + |
| 20 | + <div id="content" class="content has-sidebar"> |
| 21 | + |
| 22 | + <div class="main-content content-main"> |
| 23 | + |
| 24 | + <?php |
| 25 | + while ( have_posts() ) : |
| 26 | + the_post(); |
| 27 | + ?> |
| 28 | + |
| 29 | + <article id="post-<?php the_ID(); ?>" <?php post_class( 'image-attachment' ); ?>> |
| 30 | + <header class="entry-header"> |
| 31 | + <h1 class="entry-title"><?php the_title(); ?></h1> |
| 32 | + |
| 33 | + <footer class="entry-meta"> |
| 34 | + <?php |
| 35 | + $metadata = wp_get_attachment_metadata(); |
| 36 | + printf( |
| 37 | + '<span class="meta-prep meta-prep-entry-date">Published </span> <span class="entry-date"><time class="entry-date" datetime="%1$s">%2$s</time></span> at <a href="%3$s" title="Link to full-size image">%4$s × %5$s</a> in <a href="%6$s" title="Return to %7$s" rel="gallery">%8$s</a>.', |
| 38 | + esc_attr( get_the_date( 'c' ) ), |
| 39 | + esc_html( get_the_date() ), |
| 40 | + esc_url( wp_get_attachment_url() ), |
| 41 | + esc_html( $metadata['width'] ), |
| 42 | + esc_html( $metadata['height'] ), |
| 43 | + esc_url( get_permalink( $post->post_parent ) ), |
| 44 | + esc_attr( strip_tags( get_the_title( $post->post_parent ) ) ), |
| 45 | + esc_html( get_the_title( $post->post_parent ) ) |
| 46 | + ); |
| 47 | + ?> |
| 48 | + <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?> |
| 49 | + </footer><!-- .entry-meta --> |
| 50 | + |
| 51 | + <nav id="image-navigation" class="image-navigation" role="navigation"> |
| 52 | + <span class="previous-image"><?php previous_image_link( false, __( '← Previous', 'twentytwelve' ) ); ?></span> |
| 53 | + <span class="next-image"><?php next_image_link( false, __( 'Next →', 'twentytwelve' ) ); ?></span> |
| 54 | + </nav><!-- #image-navigation --> |
| 55 | + </header><!-- .entry-header --> |
| 56 | + |
| 57 | + <div class="entry-content"> |
| 58 | + |
| 59 | + <div class="entry-attachment"> |
| 60 | + <div class="attachment"> |
| 61 | + <?php |
| 62 | + /** |
| 63 | + * 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, |
| 64 | + * 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 |
| 65 | + */ |
| 66 | + $attachments = array_values( |
| 67 | + get_children( |
| 68 | + array( |
| 69 | + 'post_parent' => $post->post_parent, |
| 70 | + 'post_status' => 'inherit', |
| 71 | + 'post_type' => 'attachment', |
| 72 | + 'post_mime_type' => 'image', |
| 73 | + 'order' => 'ASC', |
| 74 | + 'orderby' => 'menu_order ID', |
| 75 | + ) |
| 76 | + ) |
| 77 | + ); |
| 78 | + foreach ( $attachments as $k => $attachment ) : |
| 79 | + if ( $attachment->ID == $post->ID ) { |
| 80 | + break; } |
| 81 | +endforeach; |
| 82 | + |
| 83 | + $k++; |
| 84 | + // If there is more than 1 attachment in a gallery... |
| 85 | + if ( count( $attachments ) > 1 ) : |
| 86 | + if ( isset( $attachments[ $k ] ) ) : |
| 87 | + // Get the URL of the next image attachment... |
| 88 | + $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); |
| 89 | + else : |
| 90 | + // Or get the URL of the first image attachment... |
| 91 | + $next_attachment_url = get_attachment_link( $attachments[0]->ID ); |
| 92 | + endif; |
| 93 | +else : |
| 94 | + // Or, if there's only 1 image, get the URL of the image. |
| 95 | + $next_attachment_url = wp_get_attachment_url(); |
| 96 | +endif; |
| 97 | +?> |
| 98 | + <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"> |
| 99 | + <?php |
| 100 | + $attachment_size = apply_filters( 'twentytwelve_attachment_size', array( 960, 960 ) ); |
| 101 | + echo wp_get_attachment_image( $post->ID, $attachment_size ); |
| 102 | + ?> |
| 103 | + </a> |
| 104 | + |
| 105 | + <?php if ( ! empty( $post->post_excerpt ) ) : ?> |
| 106 | + <div class="entry-caption"> |
| 107 | + <?php the_excerpt(); ?> |
| 108 | + </div> |
| 109 | + <?php endif; ?> |
| 110 | + </div><!-- .attachment --> |
| 111 | + |
| 112 | + </div><!-- .entry-attachment --> |
| 113 | + |
| 114 | + <div class="entry-description"> |
| 115 | + <?php the_content(); ?> |
| 116 | + <?php |
| 117 | + wp_link_pages( |
| 118 | + array( |
| 119 | + 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), |
| 120 | + 'after' => '</div>', |
| 121 | + ) |
| 122 | + ); |
| 123 | + ?> |
| 124 | + </div><!-- .entry-description --> |
| 125 | + |
| 126 | + </div><!-- .entry-content --> |
| 127 | + |
| 128 | + </article><!-- #post --> |
| 129 | + |
| 130 | + <?php comments_template(); ?> |
| 131 | + |
| 132 | + <?php endwhile; // end of the loop. ?> |
| 133 | + |
| 134 | + </div><!-- .main-content --> |
| 135 | + |
| 136 | + <?php get_sidebar(); ?> |
| 137 | + |
| 138 | + </div><!-- #content --> |
| 139 | + </div><!-- #primary --> |
| 140 | + |
| 141 | +<?php get_footer(); ?> |
0 commit comments