-
Notifications
You must be signed in to change notification settings - Fork 0
/
inline-gallery.php
131 lines (87 loc) · 2.86 KB
/
inline-gallery.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
<?php
/*
Plugin Name: inline-gallery
Plugin URI: http://nino-net.org
Description: Custom WordPress Gallery Plugin.
Version: 1.0
Author: Nino Mueller
Author URI: http://nino-net.org
*/
remove_shortcode('gallery');
add_shortcode('gallery', 'parse_gallery_shortcode');
function parse_gallery_shortcode($atts) {
global $post;
extract(shortcode_atts(array(
'orderby' => 'menu_order ASC, ID ASC',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'full',
'link' => 'file'
), $atts));
$args = array(
'post_type' => 'attachment',
'post_parent' => $id,
'numberposts' => -1,
'orderby' => $orderby
);
$images = get_posts($args);
$render = '';
if (!is_single() ) {
$render.=renderInlineGallery($images);
}
else {
$render.=renderBlockGallery($images);
return $render;
}
}
function renderBlockGallery($images) {
$render = '';
foreach( $images as $image) {
$caption = $image->post_excerpt;
$description = $image->post_content;
if($description == '') $description = $title;
$image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);
$img = wp_get_attachment_image_src($image->ID, $size);
$render.= '<img width="600px" height="310px" src="' . $img[0] . '" class="gallery-image" alt="' . $image_alt . '" /><br />';
}
return $render;
}
function renderInlineGallery($images) {
global $post;
$render = '';
$render.= '<div class="slideshow" id="slideshow-' . time() . rand() . '">';
$render.= '<a href="' . get_permalink($post->ID) . '">';
$render.= '<ul class="slides">';
foreach ( $images as $image ) {
$caption = $image->post_excerpt;
$description = $image->post_content;
if($description == '') $description = $title;
$image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);
$img = wp_get_attachment_image_src($image->ID, $size);
$render.= '<li><img width="720px" height="540px" src="' . $img[0] . '" class="gallery-image" alt="' . $image_alt . '" /></li>';
}
$render.= '</ul>';
$render.= '</a>';
$render.= '<span class="arrow previous"></span>';
$render.= '<span class="arrow next"></span>';
$render.= '</div>';
$render.= '<div class="mini-overview">';
$render.= '<ul class="mini-slides">';
$active = ' active';
foreach ( $images as $image ) {
$caption = $image->post_excerpt;
$description = $image->post_content;
if($description == '') $description = $title;
$image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);
$img = wp_get_attachment_image_src($image->ID, $size);
$render.= '<li class="mini-li' . $active . '"><img src="' . $img[0] . '" class="mini-image" alt="' . $image_alt . '" /></li>';
$active = "";
}
$render.= '</ul>';
$render.= '</div>';
echo $render;
}
?>