3
* The template for displaying image attachments
5
* @link http://codex.wordpress.org/Template_Hierarchy
8
* @subpackage Twenty_Twelve
9
* @since Twenty Twelve 1.0
14
<div id="primary" class="site-content">
15
<div id="content" role="main">
17
<?php while ( have_posts() ) : the_post(); ?>
19
<article id="post-<?php the_ID(); ?>" <?php post_class( 'image-attachment' ); ?>>
20
<header class="entry-header">
21
<h1 class="entry-title"><?php the_title(); ?></h1>
23
<footer class="entry-meta">
25
$metadata = wp_get_attachment_metadata();
26
printf( __( '<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>.', 'twentytwelve' ),
27
esc_attr( get_the_date( 'c' ) ),
28
esc_html( get_the_date() ),
29
esc_url( wp_get_attachment_url() ),
32
esc_url( get_permalink( $post->post_parent ) ),
33
esc_attr( strip_tags( get_the_title( $post->post_parent ) ) ),
34
get_the_title( $post->post_parent )
37
<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
38
</footer><!-- .entry-meta -->
40
<nav id="image-navigation" class="navigation" role="navigation">
41
<span class="previous-image"><?php previous_image_link( false, __( '← Previous', 'twentytwelve' ) ); ?></span>
42
<span class="next-image"><?php next_image_link( false, __( 'Next →', 'twentytwelve' ) ); ?></span>
43
</nav><!-- #image-navigation -->
44
</header><!-- .entry-header -->
46
<div class="entry-content">
48
<div class="entry-attachment">
49
<div class="attachment">
52
* 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,
53
* 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
55
$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' ) ) );
56
foreach ( $attachments as $k => $attachment ) :
57
if ( $attachment->ID == $post->ID )
61
// If there is more than 1 attachment in a gallery
62
if ( count( $attachments ) > 1 ) :
64
if ( isset( $attachments[ $k ] ) ) :
65
// get the URL of the next image attachment
66
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
68
// or get the URL of the first image attachment
69
$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
72
// or, if there's only 1 image, get the URL of the image
73
$next_attachment_url = wp_get_attachment_url();
76
<a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php
78
* Filter the image attachment size to use.
80
* @since Twenty Twelve 1.0
82
* @param array $size {
83
* @type int The attachment height in pixels.
84
* @type int The attachment width in pixels.
87
$attachment_size = apply_filters( 'twentytwelve_attachment_size', array( 960, 960 ) );
88
echo wp_get_attachment_image( $post->ID, $attachment_size );
91
<?php if ( ! empty( $post->post_excerpt ) ) : ?>
92
<div class="entry-caption">
93
<?php the_excerpt(); ?>
96
</div><!-- .attachment -->
98
</div><!-- .entry-attachment -->
100
<div class="entry-description">
101
<?php the_content(); ?>
102
<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
103
</div><!-- .entry-description -->
105
</div><!-- .entry-content -->
107
</article><!-- #post -->
109
<?php comments_template(); ?>
111
<?php endwhile; // end of the loop. ?>
113
</div><!-- #content -->
114
</div><!-- #primary -->
116
<?php get_footer(); ?>
b'\\ No newline at end of file'