Get the Image - Version 0.3.3

Version Description

Download this release

Release Info

Developer greenshady
Plugin Icon 128x128 Get the Image
Version 0.3.3
Comparing to
See all releases

Code changes from version 0.3.2 to 0.3.3

Files changed (3) hide show
  1. get-the-image.php +27 -24
  2. readme.css +37 -251
  3. readme.txt +7 -2
get-the-image.php CHANGED
@@ -3,16 +3,16 @@
3
  * Plugin Name: Get The Image
4
  * Plugin URI: http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin
5
  * Description: This is a highly intuitive script that can grab an image by custom field input, post attachment, or extracting it from the post's content.
6
- * Version: 0.3.2
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
  *
10
- * Get the Image - A highly-intuitive image script
11
- * Loads images that are related to the post in some way
12
- * Offers an image-based representation of WordPress posts
13
  *
14
  * @copyright 2008 - 2009
15
- * @version 0.3.2
16
  * @author Justin Tadlock
17
  * @link http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin
18
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@@ -25,18 +25,20 @@
25
  */
26
 
27
  /**
28
- * This is a highly intuitive function that gets images
29
- * It first calls for custom field keys
30
- * If no custom field key is set, check for images attached to post
31
- * Check for image order if looking for attached images
32
- * Scan the post for images if $image_scan = true
33
- * Check for default image if $default_image = true
34
- * If an image is found, call display_the_image() to format it
35
  *
36
- * Entirely rewrote the system in 0.3
37
- * Arguments should be in an array (preferably)
38
  *
39
- * @todo Add in the functionality to input a post ID
 
 
40
  *
41
  * @since 0.1
42
  * @param array|string $args Mixed parameters for what image to get
@@ -88,8 +90,7 @@ function get_the_image( $args = array() ) {
88
  if ( $image )
89
  $image = display_the_image( $args, $image );
90
 
91
- else
92
- $image = '<!-- No images were added to this post. -->';
93
 
94
  if ( $echo && $echo !== 'false' && $echo !== '0' && $format !== 'array' )
95
  echo $image;
@@ -104,6 +105,7 @@ function get_the_image( $args = array() ) {
104
  * If an image is found, it is returned
105
  *
106
  * @since 0.3
 
107
  * @param array $args
108
  * @return array|bool
109
  */
@@ -111,10 +113,10 @@ function image_by_custom_field( $args = array() ) {
111
 
112
  extract( $args );
113
 
114
- if( !$post_id )
115
  global $post;
116
 
117
- if( isset( $custom_key ) ) :
118
  foreach ( $custom_key as $custom ) :
119
  $image = get_post_meta( $post->ID, $custom, true );
120
  if ( $image ) :
@@ -136,6 +138,7 @@ function image_by_custom_field( $args = array() ) {
136
  * The loop only breaks once $order_of_image is reached
137
  *
138
  * @since 0.3
 
139
  * @param array $args
140
  * @return array|bool
141
  */
@@ -146,9 +149,7 @@ function image_by_attachment( $args = array() ) {
146
  if ( !$post_id )
147
  global $post;
148
 
149
- /*
150
- * Get attachments
151
- */
152
  $attachments = get_children( array( 'post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) );
153
 
154
  if ( empty( $attachments ) )
@@ -172,6 +173,7 @@ function image_by_attachment( $args = array() ) {
172
  * Shouldn't use if using large images within posts, better to use the other options
173
  *
174
  * @since 0.3
 
175
  * @param array $args
176
  * @return array|bool
177
  */
@@ -213,6 +215,7 @@ function image_by_default( $args = array() ) {
213
  * Should only be called if there is an image to display, but will handle it if not
214
  *
215
  * @since 0.1
 
216
  * @param array $args
217
  * @param array $arr Array of image info ($image, $classes, $alt, $caption)
218
  * @return string $image Formatted image (w/link to post if the option is set)
@@ -227,13 +230,13 @@ function display_the_image( $args = array(), $arr = false ) {
227
 
228
  extract( $args );
229
 
 
 
230
  if ( $width )
231
  $width = ' width="' . $width . '"';
232
  if ( $height )
233
  $height = ' height="' . $height . '"';
234
 
235
- $img = $image;
236
-
237
  if ( is_array( $custom_key ) ) :
238
  foreach ( $custom_key as $key ) :
239
  if ( $key !== 'false' && $key !== '0' ) :
3
  * Plugin Name: Get The Image
4
  * Plugin URI: http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin
5
  * Description: This is a highly intuitive script that can grab an image by custom field input, post attachment, or extracting it from the post's content.
6
+ * Version: 0.3.3
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
  *
10
+ * Get the Image - A highly-intuitive image script.
11
+ * Loads images that are related to the post in some way.
12
+ * Offers an image-based representation of WordPress posts.
13
  *
14
  * @copyright 2008 - 2009
15
+ * @version 0.3.3
16
  * @author Justin Tadlock
17
  * @link http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin
18
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
25
  */
26
 
27
  /**
28
+ * This is a highly intuitive function that gets images.
29
+ * It first calls for custom field keys.
30
+ * If no custom field key is set, check for images attached to post.
31
+ * Check for image order if looking for attached images.
32
+ * Scan the post for images if $image_scan = true.
33
+ * Check for default image if $default_image = true.
34
+ * If an image is found, call display_the_image() to format it.
35
  *
36
+ * Entirely rewrote the system in 0.3.
37
+ * Arguments should be in an array (preferably).
38
  *
39
+ * In 0.3.3, added the 'get_the_image' filter hook.
40
+ *
41
+ * @todo Add in the functionality to input a post ID.
42
  *
43
  * @since 0.1
44
  * @param array|string $args Mixed parameters for what image to get
90
  if ( $image )
91
  $image = display_the_image( $args, $image );
92
 
93
+ $image = apply_filters( 'get_the_image', $image );
 
94
 
95
  if ( $echo && $echo !== 'false' && $echo !== '0' && $format !== 'array' )
96
  echo $image;
105
  * If an image is found, it is returned
106
  *
107
  * @since 0.3
108
+ * @global $post The current post's DB object.
109
  * @param array $args
110
  * @return array|bool
111
  */
113
 
114
  extract( $args );
115
 
116
+ if ( !$post_id )
117
  global $post;
118
 
119
+ if ( isset( $custom_key ) ) :
120
  foreach ( $custom_key as $custom ) :
121
  $image = get_post_meta( $post->ID, $custom, true );
122
  if ( $image ) :
138
  * The loop only breaks once $order_of_image is reached
139
  *
140
  * @since 0.3
141
+ * @global $post The current post's DB object.
142
  * @param array $args
143
  * @return array|bool
144
  */
149
  if ( !$post_id )
150
  global $post;
151
 
152
+ /* Get attachments */
 
 
153
  $attachments = get_children( array( 'post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) );
154
 
155
  if ( empty( $attachments ) )
173
  * Shouldn't use if using large images within posts, better to use the other options
174
  *
175
  * @since 0.3
176
+ * @global $post The current post's DB object.
177
  * @param array $args
178
  * @return array|bool
179
  */
215
  * Should only be called if there is an image to display, but will handle it if not
216
  *
217
  * @since 0.1
218
+ * @global $post The current post's DB object.
219
  * @param array $args
220
  * @param array $arr Array of image info ($image, $classes, $alt, $caption)
221
  * @return string $image Formatted image (w/link to post if the option is set)
230
 
231
  extract( $args );
232
 
233
+ $img = $image;
234
+
235
  if ( $width )
236
  $width = ' width="' . $width . '"';
237
  if ( $height )
238
  $height = ' height="' . $height . '"';
239
 
 
 
240
  if ( is_array( $custom_key ) ) :
241
  foreach ( $custom_key as $key ) :
242
  if ( $key !== 'false' && $key !== '0' ) :
readme.css CHANGED
@@ -1,247 +1,11 @@
1
  /* Reset values */
2
- html, body, div, span, object, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
3
- margin: 0;
4
- padding: 0;
5
- vertical-align: baseline;
6
- outline: none;
7
- font-size: 100%;
8
- background: transparent;
9
- border: none;
10
- text-decoration: none;
11
- }
12
-
13
- /*
14
- * Get rid of deprecated and non-semantic elements
15
- * These elements should not be used and replaced with proper alternatives
16
- */
17
- b, i, hr, u, center, menu, layer, s, strike, font, xmp {
18
- margin: 0;
19
- padding: 0;
20
- vertical-align: baseline;
21
- outline: none;
22
- font-size: 100%;
23
- font-weight: normal;
24
- font-style: normal;
25
- background: transparent;
26
- border: none;
27
- text-decoration: none;
28
- }
29
- font {
30
- color: #333;
31
- }
32
- center {
33
- text-align: left;
34
- }
35
-
36
- /* End deprecated elements */
37
-
38
-
39
- /* Body */
40
- body {
41
- line-height: 24px;
42
- font-family: Cambria, Georgia, Times, "Times New Roman", serif;
43
- color: #333;
44
- background: #fff;
45
- }
46
-
47
- /* Headers */
48
- h1, h2, h3, h4, h5, h6 {
49
- font-style: normal;
50
- font-weight: normal;
51
- margin: 0 0 21px 0;
52
- }
53
- h1 {
54
- font-size: 1.8em;
55
- }
56
- h2 {
57
- font-size: 1.7em;
58
- }
59
- h3 {
60
- font-size: 1.55em;;
61
- }
62
- h4 {
63
- font-size: 1.4em;
64
- }
65
- h5 {
66
- font-size: 1.25em;
67
- }
68
- h6 {
69
- font-size: 1.1em;
70
- }
71
-
72
- /* Paragraphs */
73
- p {
74
- margin: 0 0 21px 0;
75
- }
76
-
77
- /* Lists */
78
- ol, ul {
79
- list-style: none;
80
- }
81
- ul {
82
- list-style: disc;
83
- margin: 0 0 21px 1.5em;
84
- }
85
- ol {
86
- list-style-type: decimal;
87
- margin: 0 0 21px 3em;
88
- }
89
- ol ol {
90
- list-style: upper-roman;
91
- }
92
- ol ol ol {
93
- list-style: lower-roman;
94
- }
95
- ol ol ol ol {
96
- list-style: upper-alpha;
97
- }
98
- ol ol ol ol ol {
99
- list-style: lower-alpha;
100
- }
101
- ul ul, ol ol, ul ol, ol ul {
102
- margin-bottom: 0;
103
- }
104
- dl {
105
- margin: 0 0 18px 3px;
106
- }
107
- dl dt {
108
- font-weight: bold;
109
- margin: 12px 0 0 0;
110
- }
111
- dl dd {
112
- margin: 6px 0 0 1.5em;
113
- }
114
-
115
- /* Text elements */
116
- strong {
117
- font-weight: bold;
118
- }
119
- strong strong {
120
- font-weight: normal;
121
- }
122
- em, cite {
123
- font-style: italic;
124
- }
125
- em em, cite cite {
126
- font-style: normal;
127
- }
128
- abbr {
129
- cursor: help;
130
- }
131
- acronym {
132
- text-transform: uppercase;
133
- border-bottom: 1px dashed #666;
134
- cursor: help;
135
- }
136
- big {
137
- font-size: 120%;
138
- }
139
- small, sup, sub {
140
- font-size: 80%;
141
- }
142
- sup {
143
- vertical-align: baseline;
144
- position: relative;
145
- bottom: 0.3em;
146
- }
147
- sub {
148
- vertical-align: baseline;
149
- position: relative;
150
- top: 0.3em;
151
- }
152
- address {
153
- font-style: italic;
154
- margin: 0 0 21px 0;
155
- }
156
- li address, dd address {
157
- margin: 0;
158
- }
159
-
160
- /* Blockquotes */
161
- blockquote {
162
- margin: 0 2.5em;
163
- font-style: normal;
164
- }
165
- blockquote em, blockquote cite {
166
- font-style: italic;
167
- }
168
- blockquote, q {
169
- quotes: none;
170
- }
171
- blockquote:before, blockquote:after, q:before, q:after {
172
- content: '';
173
- content: none;
174
- }
175
-
176
- /* Links */
177
- a {
178
- cursor: pointer;
179
- }
180
- a img {
181
- border: none;
182
- }
183
-
184
- /* Code */
185
- pre {
186
- font: .9em Monaco, monospace, Courier, "Courier New";
187
- line-height: 21px;
188
- margin-bottom: 21px;
189
- padding: 9px;
190
- }
191
- code {
192
- font: .9em Monaco, monospace, Courier, "Courier New";
193
- }
194
- pre code {
195
- font-size: 1em;
196
- }
197
-
198
- /* Delete and insert */
199
- ins, dfn {
200
- font-style: italic;
201
- text-decoration: none;
202
- border-bottom: 1px solid #666;
203
- }
204
- del {
205
- text-decoration: line-through;
206
- }
207
-
208
- /* Object */
209
- object {
210
- margin-bottom: 21px;
211
- }
212
-
213
- /* Forms */
214
- input, textarea {
215
- font-size: 1em;
216
- font-family: Cambria, Georgia, Times, "Times New Roman", serif;
217
- padding: 3px;
218
- }
219
- :focus {
220
- outline: none;
221
- }
222
- form label {
223
- cursor: pointer;
224
- }
225
-
226
- /* Tables */
227
- table {
228
- border-collapse: collapse;
229
- border-spacing: 0;
230
- margin-bottom: 21px;
231
- }
232
- th, td {
233
- text-align: left;
234
- }
235
-
236
- /* Horizontal rule */
237
- hr {
238
- margin-bottom: 21px;
239
- }
240
 
241
  body {
242
- width: 780px;
243
- margin: 36px auto;
244
- font: 14px/21px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
 
245
  }
246
  /* Links */
247
  a:link, a:visited {
@@ -253,17 +17,14 @@ a:hover, a:active {
253
  }
254
  /* Headers */
255
  h1, h2, h3, h4, h5, h6 {
256
- margin-top: 36px;
257
- color: #666;
258
- font-family: Cambria, Georgia, Times, "Times New Roman", serif;
259
- }
260
- h1, h2 {
261
- padding-bottom: 12px;
262
- border-bottom: 1px solid #ccc;
263
  }
264
  h1 {
265
- margin-top: 0;
266
- font-size: 2.1em;
267
  }
268
  code {
269
  padding: 0 3px;
@@ -273,8 +34,33 @@ pre code {
273
  padding: 0;
274
  }
275
  pre {
276
- overflow: auto;
277
  padding: 9px;
278
  background: #eee;
279
  border: 1px solid #ccc;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  }
1
  /* Reset values */
2
+ html,body,div,span,object,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;vertical-align:baseline;outline:none;font-size:100%;background:transparent;border:none;text-decoration:none}b,i,hr,u,center,menu,layer,s,strike,font,xmp{margin:0;padding:0;vertical-align:baseline;outline:none;font-size:100%;font-weight:normal;font-style:normal;background:transparent;border:none;text-decoration:none}font{color:#333}center{text-align:left}body{line-height:25px;font-family:Cambria,Georgia,Times,"Times New Roman",serif;color:#333;background:#fff}h1,h2,h3,h4,h5,h6{font-style:normal;font-weight:normal;margin:0 0 25px 0}h1{font-size:1.8em}h2{font-size:1.7em}h3{font-size:1.55em;}h4{font-size:1.4em}h5{font-size:1.25em}h6{font-size:1.1em}p{margin:0 0 25px 0}ol,ul{list-style:none}ul{list-style:disc;margin:0 0 25px 2.5em}ol{list-style-type:decimal;margin:0 0 25px 3em}ol ol{list-style:upper-roman}ol ol ol{list-style:lower-roman}ol ol ol ol{list-style:upper-alpha}ol ol ol ol ol{list-style:lower-alpha}ul ul,ol ol,ul ol,ol ul{margin-bottom:0}dl{margin:0 0 25px 5px}dl dt{font-weight:bold;margin:10px 0 0 0}dl dd{margin:5px 0 0 1.5em}strong{font-weight:bold}strong strong{font-weight:normal}em,cite{font-style:italic}em em,cite cite{font-style:normal}abbr{cursor:help}acronym{text-transform:uppercase;border-bottom:1px dashed #666;cursor:help}big{font-size:120%}small,sup,sub{font-size:80%}sup{vertical-align:baseline;position:relative;bottom:0.3em}sub{vertical-align:baseline;position:relative;top:0.3em}address{font-style:italic;margin:0 0 25px 0}li address,dd address{margin:0}blockquote{margin:0 25px;font-style:normal}blockquote em,blockquote cite{font-style:italic}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}a{cursor:pointer}a img{border:none}pre{overflow:auto;font:.9em Monaco,monospace,Courier,"Courier New";line-height:25px;margin-bottom:25px;padding:10px}code{font:.9em Monaco,monospace,Courier,"Courier New"}pre code{font-size:1em}ins,dfn{font-style:italic;text-decoration:none;border-bottom:1px solid #666}del{text-decoration:line-through}object{margin-bottom:25px}input,textarea{font-size:1em;font-family:Cambria,Georgia,Times,"Times New Roman",serif;padding:3px}:focus{outline:none}form label{cursor:pointer}option{padding:1px 2px}table{border-collapse:collapse;border-spacing:0;margin-bottom:25px}th,td{text-align:left}hr{margin-bottom:25px}img.wp-smiley{max-height:12px;margin:0;padding:0;border:none}.gallery{display:block;text-align:center;margin-bottom:25px !important}.alignleft,.left{float:left;margin-right:20px}.alignright,.right{float:right;margin-left:20px}.aligncenter,.center{display:block;margin:0 auto 25px auto}.alignnone,.block{clear:both;margin:0 0 25px 0}.clear{clear:both}img.alignleft,img.alignright{display:inline}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  body {
5
+ width: 750px;
6
+ margin: 36px auto 60px auto;
7
+ font: 15px/21px Arial, 'Helvetica Neue', Helvetica, sans-serif;
8
+ font: 16px/25px Georgia, Times, 'Times New Roman', serif;
9
  }
10
  /* Links */
11
  a:link, a:visited {
17
  }
18
  /* Headers */
19
  h1, h2, h3, h4, h5, h6 {
20
+ margin: 40px 0 30px 0;
21
+ color: #000;
22
+ font-weight: bold;
23
+ font-family: Arial, sans-serif;
 
 
 
24
  }
25
  h1 {
26
+ margin-top: 80px;
27
+ font-size: 2.2em;
28
  }
29
  code {
30
  padding: 0 3px;
34
  padding: 0;
35
  }
36
  pre {
 
37
  padding: 9px;
38
  background: #eee;
39
  border: 1px solid #ccc;
40
+ }
41
+ ul {
42
+ list-style: square;
43
+ }
44
+ p.first {
45
+ font-size: 21px;
46
+ }
47
+ p.second {
48
+ font-size: 15px;
49
+ }
50
+ ul.space li {
51
+ margin-bottom: 10px;
52
+ }
53
+ .section {
54
+ overflow: hidden;
55
+ }
56
+
57
+ .columns-2 {
58
+ float: left;
59
+ width: 350px;
60
+ margin: 0 0 21px 25px;
61
+ }
62
+ .columns-3 {
63
+ float: left;
64
+ width: 230px;
65
+ margin: 0 0 21px 20px;
66
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: greenshady
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3687060
4
  Tags: image, images, thumbnail
5
  Requires at least: 2.5
6
- Tested up to: 2.7.1
7
- Stable tag: 0.3.2
8
 
9
  An easy-to-use image script for adding things such as thumbnails and feature images.
10
 
@@ -57,6 +57,11 @@ You can view this plugin in action on my <a href="http://justintadlock.com" titl
57
 
58
  Ealier versions were not documented well.
59
 
 
 
 
 
 
60
  **Version 0.3.2**
61
 
62
  * General code cleanup.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3687060
4
  Tags: image, images, thumbnail
5
  Requires at least: 2.5
6
+ Tested up to: 2.8
7
+ Stable tag: 0.3.3
8
 
9
  An easy-to-use image script for adding things such as thumbnails and feature images.
10
 
57
 
58
  Ealier versions were not documented well.
59
 
60
+ **Version 0.3.3**
61
+
62
+ * General code cleanup
63
+ * Added the `get_the_image` filter hook.
64
+
65
  **Version 0.3.2**
66
 
67
  * General code cleanup.