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