| [ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * The template for displaying image attachments. 4 * 5 * @package WordPress 6 * @subpackage Twenty_Twelve 7 * @since Twenty Twelve 1.0 8 */ 9 10 get_header(); ?> 11 12 <div id="primary" class="image-attachment"> 13 <div id="content" role="main"> 14 15 <?php while ( have_posts() ) : the_post(); ?> 16 17 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 18 <header class="entry-header"> 19 <h1 class="entry-title"><?php the_title(); ?></h1> 20 21 <div class="entry-meta"> 22 <?php 23 $metadata = wp_get_attachment_metadata(); 24 printf( __( '<span class="meta-prep meta-prep-entry-date">Published </span> <span class="entry-date"><time class="entry-date" datetime="%1$s" pubdate>%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>', 'twentytwelve' ), 25 esc_attr( get_the_date( 'c' ) ), 26 esc_html( get_the_date() ), 27 esc_url( wp_get_attachment_url() ), 28 $metadata['width'], 29 $metadata['height'], 30 esc_url( get_permalink( $post->post_parent ) ), 31 esc_attr( strip_tags( get_the_title( $post->post_parent ) ) ), 32 get_the_title( $post->post_parent ) 33 ); 34 ?> 35 <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?> 36 </div><!-- .entry-meta --> 37 38 <nav id="image-navigation" role="navigation"> 39 <span class="previous-image"><?php previous_image_link( false, __( '← Previous', 'twentytwelve' ) ); ?></span> 40 <span class="next-image"><?php next_image_link( false, __( 'Next →', 'twentytwelve' ) ); ?></span> 41 </nav><!-- #image-navigation --> 42 </header><!-- .entry-header --> 43 44 <div class="entry-content"> 45 46 <div class="entry-attachment"> 47 <div class="attachment"> 48 <?php 49 /** 50 * 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, 51 * 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 52 */ 53 $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' ) ) ); 54 foreach ( $attachments as $k => $attachment ) { 55 if ( $attachment->ID == $post->ID ) 56 break; 57 } 58 $k++; 59 // If there is more than 1 attachment in a gallery 60 if ( count( $attachments ) > 1 ) { 61 if ( isset( $attachments[ $k ] ) ) 62 // get the URL of the next image attachment 63 $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 64 else 65 // or get the URL of the first image attachment 66 $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID ); 67 } else { 68 // or, if there's only 1 image, get the URL of the image 69 $next_attachment_url = wp_get_attachment_url(); 70 } 71 ?> 72 <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php 73 $attachment_size = apply_filters( 'twentytwelve_attachment_size', 800 ); 74 echo wp_get_attachment_image( $post->ID, array( $attachment_size, $attachment_size ) ); 75 ?></a> 76 77 <?php if ( ! empty( $post->post_excerpt ) ) : ?> 78 <div class="entry-caption"> 79 <?php the_excerpt(); ?> 80 </div> 81 <?php endif; ?> 82 </div><!-- .attachment --> 83 84 </div><!-- .entry-attachment --> 85 86 <div class="entry-description"> 87 <?php the_content(); ?> 88 <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?> 89 </div><!-- .entry-description --> 90 91 </div><!-- .entry-content --> 92 93 </article><!-- #post --> 94 95 <?php comments_template(); ?> 96 97 <?php endwhile; // end of the loop. ?> 98 99 </div><!-- #content --> 100 </div><!-- #primary --> 101 102 <?php get_footer(); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Mar 20 03:55:56 2012 | Hosted by follow the white rabbit. |