forked from obenland/the-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.php
More file actions
106 lines (95 loc) · 3.3 KB
/
image.php
File metadata and controls
106 lines (95 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/** image.php
*
* The template for displaying image attachments.
*
* @author Konstantin Obenland
* @package WordPress
* @subpackage The Bootstrap
* @since 1.0.0 - 05.02.2012
*/
get_header();
$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'
)));
$total_images = count($attachments);
//Get position of current pic
foreach ( $attachments as $k => $attachment ) {
if ( $attachment->ID == $post->ID )
break;
}
the_post();
?>
<section id="primary" class="image-attachment span12">
<div id="content" role="main">
<nav id="nav-single" class="well clearfix">
<p class="gallery-link alignleft">
<a href="<?php echo get_permalink( $post->post_parent ); ?>">
<?php
printf(
'« %1$s (%2$s)',
get_the_title($post->post_parent),
sprintf(
'%d %s',
$total_images,
_n('image', 'images', $total_images, 'the-bootstrap')
)
);
?>
</a>
</p>
<p class="nav-links alignright">
<?php
edit_post_link( __( 'Edit', 'the-bootstrap' ), ' <span class="edit-link label">', '</span><span class="sep"> </span>' );
$reply = __( 'Leave a comment', 'the-bootstrap' );
comments_popup_link( $reply, $reply );
if ( isset($attachments[$k-1]) )
echo ' — <a href="' . get_permalink( $attachments[$k-1]->ID ) . '">' . __( '« Previous Photo', 'the-bootstrap' ) . '</a>';
if ( isset($attachments[$k+1]) )
echo ' — <a href="' . get_permalink( $attachments[$k+1]->ID ) . '">' . __( 'Next Photo »', 'the-bootstrap' ) . '</a>';
?>
</p>
</nav><!-- #nav-single -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content entry-attachment">
<figure class="attachment">
<?php
// If there is more than 1 attachment in a gallery
if ( $total_images > 1 ) {
if ( isset( $attachments[ ++$k ] ) ) {
// get the URL of the next image attachment
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
}
else {
// or get the URL of the first image attachment
$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
}
} else {
// or, if there's only 1 image, get the URL of the image
$next_attachment_url = wp_get_attachment_url();
}
?>
<a href="<?php echo $next_attachment_url; ?>" title="<?php the_title_attribute(); ?>" rel="attachment" class="thumbnail">
<?php echo wp_get_attachment_image( $post->ID, 'full', false, array( 'class' => '' ) ); ?>
</a>
<?php if ( $post->post_excerpt ) : ?>
<figcaption class="entry-caption">
<?php the_excerpt(); ?>
</figcaption>
<?php endif; ?>
</figure><!-- .attachment -->
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->
</div><!-- #content -->
</section><!-- #primary -->
<div class="span8"><?php comments_template( '', true ); ?></div>
<?php
get_sidebar( 'image' );
get_footer();
/* End of file index.php */
/* Location: ./wp-content/themes/the-bootstrap/index.php */