-
Notifications
You must be signed in to change notification settings - Fork 5
/
content-image.php
136 lines (119 loc) · 5.99 KB
/
content-image.php
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* The template for displaying the Loop Content.
*
* @package StormBringer
* @since StormBringer 0.0.1
*/
?>
<article id="attachment-<?php the_ID(); ?>" <?php post_class(''); ?>>
<?php // only show edit button if user has permission to edit posts
global $user_level;
if ( ($user_level > 0 && !is_singular()) || ( !is_admin_bar_showing() && $user_level > 0 && is_singular() ) ) {
$edit_link = '<a href="' . get_edit_post_link( get_the_ID() ) . '" class="btn btn-success edit-post pull-right"><span class="glyphicon glyphicon-pencil"></span> ' . __( 'Edit', 'stormbringer' ) . '</a>';
}
?>
<?php if (is_single() || is_page() || is_singular()) { ?>
<header class="page-header">
<?php echo $edit_link; ?>
<h1 class="page-title"><?php the_title(); ?></h1>
</header>
<?php } else { ?>
<header class="entry-header">
<?php echo $edit_link; ?>
<h2 class="entry-title">
<a class="entry-title" title="<?php printf(esc_attr__('Link to %s', 'stormbringer'), the_title_attribute('echo=0')); ?>" rel="bookmark" href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
</header>
<?php } ?>
<!-- /.entry-header -->
<footer class="entry-meta">
<p class="entry-date">
<i class="glyphicon glyphicon-calendar"></i>
<time datetime="<?php echo the_time('c'); ?>" class="updated"><?php echo get_the_date(esc_attr__('F j, Y', 'stormbringer')); ?></time>
</p>
<p class="entry-author">
<i class="glyphicon glyphicon-user"></i> <?php _e('By', 'stormbringer'); ?>
<span class="vcard author"><span class="fn"><?php the_author_posts_link(); ?></span></span>
</p>
<?php if (comments_open() && !is_page()) : ?>
<p class="comments-link">
<?php comments_popup_link('<span class="leave-reply"><span class="glyphicon glyphicon-comment"></span> ' . __('Leave a comment', 'stormbringer') . '</span>', '<span class="glyphicon glyphicon-comment"></span> ' . _x('1 comment', 'comments number', 'stormbringer'), '<span class="glyphicon glyphicon-comment"></span> ' . _x('% comments', 'comments number', 'stormbringer')); ?>
</p>
<?php endif; // End if comments_open() ?>
<?php
$metadata = wp_get_attachment_metadata();
if ($metadata['width'] && $metadata['height']): ?>
<p class="entry-size">
<?php printf(__('<span class="%1$s"><span class="glyphicon glyphicon-picture"></span> Size:</span> %2$s × %3$s', 'stormbringer'), 'intro', $metadata['width'], $metadata['height']); ?>
</p>
<?php endif; // End if $metadata ?>
<?php
$categories_list = get_the_category_list(__(', ', 'stormbringer'));
if ($categories_list): ?>
<p class="entry-categories">
<?php printf(__('<span class="%1$s"><span class="glyphicon glyphicon-book"></span> Categories:</span> %2$s', 'stormbringer'), 'intro', $categories_list); ?>
</p>
<?php endif; // End if $categories_list ?>
<?php
$tags_list = get_the_tag_list('', __(', ', 'stormbringer'));
if ($tags_list): ?>
<p class="entry-tags">
<?php printf(__('<span class="%1$s"><span class="glyphicon glyphicon-tags"></span> Tags:</span> %2$s', 'stormbringer'), 'intro', $tags_list); ?>
</p>
<?php endif; // End if $tags_list ?>
</footer>
<!-- /.entry-meta -->
<div class="entry-content">
<div class="entry-attachment">
<?php
$imgmeta = wp_get_attachment_metadata($post->ID);
/**
* 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,
* 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
*/
$k = 0;
$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'
)));
foreach ($attachments as $k => $attachment) {
if ($attachment->ID == $post->ID)
break;
}
$k++;
// If there is more than 1 attachment in a gallery
if (count($attachments) > 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 echo esc_attr(get_the_title()); ?>"
rel="attachment"><?php
$attachment_size = apply_filters('stormbringer_attachment_size', array(800, 800)); // filterable image width with, essentially, no limit for image height.
echo wp_get_attachment_image($post->ID, $attachment_size);
?></a>
</div>
<!-- .entry-attachment -->
<?php if (!empty($post->post_excerpt)) : ?>
<div class="entry-caption">
<?php the_excerpt(); ?>
</div>
<?php endif; ?>
</div>
<!-- /.entry-content -->
</article>
<!-- /#post -->