-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.php
More file actions
108 lines (66 loc) · 3.29 KB
/
image.php
File metadata and controls
108 lines (66 loc) · 3.29 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
107
108
<?php get_header(); ?>
<div class="content section-inner">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="posts">
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="content-inner">
<div class="featured-media">
<?php $image_array = wp_get_attachment_image_src( $post->ID, 'full', false ); ?>
<a href="<?php echo esc_url( $image_array[0] ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment">
<?php echo wp_get_attachment_image( $post->ID, 'post-image' ); ?>
</a>
</div><!-- .featured-media -->
<div class="post-header">
<h2 class="post-title"><?php echo basename( get_attached_file( $post->ID ) ); ?></h2>
<div class="post-meta">
<span><?php echo __( 'Uploaded', 'nayncuration' ) . ' ' . get_the_time( get_option( 'date_format' ) ); ?></span>
<span class="date-sep">/</span>
<span><?php echo __( 'Width:', 'nayncuration' ) . ' ' . $image_array[1] . ' px'; ?></span>
<span class="date-sep">/</span>
<span><?php echo __( 'Height:', 'nayncuration' ) . ' ' . $image_array[2] . ' px'; ?></span>
</div>
</div><!-- .post-header -->
<?php if ( has_excerpt() ) : ?>
<div class="post-content">
<?php the_excerpt(); ?>
</div><!-- .post-content -->
<?php endif; ?>
</div><!-- .content-inner -->
<div class="post-nav">
<?php
// Get images in the current attachments gallery, and get the next and previous from it
$attachments = array_values( get_children( array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'post_mime_type' => 'image',
'post_parent' => $post->post_parent,
'post_status' => 'inherit',
'post_type' => 'attachment',
) ) );
foreach ( $attachments as $k => $attachment ) :
if ( $attachment->ID == $post->ID )
break;
endforeach;
$l = $k - 1;
$k++;
if ( isset( $attachments[ $k ] ) ) :
// Get the URL of the next image attachment
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
$prev_attachment_url = get_attachment_link( $attachments[ $l ]->ID );
else :
// ...Or get the URL of the first image attachment
$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
endif;
?>
<a href="<?php echo esc_url( $prev_attachment_url ); ?>" class="post-nav-older" rel="attachment"><?php _e( '« Previous<span> attachment</span>', 'nayncuration' ); ?></a>
<a href="<?php echo esc_url( $next_attachment_url ); ?>" class="post-nav-newer" rel="attachment"><?php _e( 'Next<span> attachment</span> »', 'nayncuration' ); ?></a>
<div class="clear"></div>
</div><!-- .post-nav -->
<?php comments_template( '', true ); ?>
<?php endwhile; else: ?>
<p><?php _e( "We couldn't find any posts that matched your query. Please try again.", "nayncuration" ); ?></p>
<?php endif; ?>
</div><!-- .post -->
</div><!-- .posts -->
</div><!-- .content section-inner -->
<?php get_footer(); ?>