Get the Image - Version 0.9.0

Version Description

Download this release

Release Info

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

Code changes from version 0.8.1 to 0.9.0

Files changed (8) hide show
  1. get-the-image.php +71 -27
  2. readme.css +0 -77
  3. readme.html +0 -220
  4. readme.md +303 -0
  5. readme.txt +70 -40
  6. screenshot-1.jpg +0 -0
  7. screenshot-2.jpg +0 -0
  8. screenshot-3.jpg +0 -0
get-the-image.php CHANGED
@@ -2,11 +2,13 @@
2
  /**
3
  * Plugin Name: Get The Image
4
  * Plugin URI: http://themehybrid.com/plugins/get-the-image
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.8.1
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
- *
 
 
10
  * Get the Image - An advanced post image script for WordPress.
11
  *
12
  * Get the Image was created to be a highly-intuitive image script that displays post-specific images (an
@@ -23,9 +25,9 @@
23
  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24
  *
25
  * @package GetTheImage
26
- * @version 0.8.1
27
  * @author Justin Tadlock <justin@justintadlock.com>
28
- * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
29
  * @link http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin
30
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
31
  */
@@ -54,29 +56,47 @@ add_action( 'added_post_meta', 'get_the_image_delete_cache_by_meta', 10, 2 );
54
  * @return string|array The HTML for the image. | Image attributes in an array.
55
  */
56
  function get_the_image( $args = array() ) {
 
57
 
58
  /* Set the default arguments. */
59
  $defaults = array(
60
- 'meta_key' => array( 'Thumbnail', 'thumbnail' ), // array|string
 
61
  'post_id' => get_the_ID(),
 
 
 
 
62
  'attachment' => true,
63
- 'the_post_thumbnail' => true, // WP 2.9+ image function
64
- 'size' => 'thumbnail',
65
  'default_image' => false,
 
 
 
66
  'order_of_image' => 1,
 
 
67
  'link_to_post' => true,
68
  'image_class' => false,
69
- 'image_scan' => false,
70
  'width' => false,
71
  'height' => false,
72
- 'format' => 'img',
 
 
 
 
 
 
73
  'meta_key_save' => false,
74
  'thumbnail_id_save' => false, // Set 'featured image'.
75
- 'callback' => null,
76
  'cache' => true,
77
- 'before' => '',
78
- 'after' => '',
 
79
  'echo' => true,
 
 
80
  'custom_key' => null, // @deprecated 0.6. Use 'meta_key'.
81
  'default_size' => null, // @deprecated 0.5. Use 'size'.
82
  );
@@ -87,6 +107,10 @@ function get_the_image( $args = array() ) {
87
  /* Merge the input arguments and the defaults. */
88
  $args = wp_parse_args( $args, $defaults );
89
 
 
 
 
 
90
  /* If $default_size is given, overwrite $size. */
91
  if ( !is_null( $args['default_size'] ) )
92
  $args['size'] = $args['default_size']; // Deprecated 0.5 in favor of $size
@@ -172,13 +196,14 @@ function get_the_image( $args = array() ) {
172
  $out = array();
173
 
174
  /* Get the image attributes. */
175
- $atts = wp_kses_hair( $image_html, array( 'http' ) );
176
 
177
  /* Loop through the image attributes and add them in key/value pairs for the return array. */
178
  foreach ( $atts as $att )
179
  $out[ $att['name'] ] = $att['value'];
180
 
181
- $out['url'] = $out['src']; // @deprecated 0.5 Use 'src' instead of 'url'.
 
182
 
183
  /* Return the array of attributes. */
184
  return $out;
@@ -261,11 +286,14 @@ function get_the_image_by_post_thumbnail( $args = array() ) {
261
  /* Get the attachment image source. This should return an array. */
262
  $image = wp_get_attachment_image_src( $post_thumbnail_id, $size );
263
 
264
- /* Get the attachment excerpt to use as alt text. */
265
- $alt = trim( strip_tags( get_post_field( 'post_excerpt', $post_thumbnail_id ) ) );
 
 
 
266
 
267
  /* Return both the image URL and the post thumbnail ID. */
268
- return array( 'src' => $image[0], 'post_thumbnail_id' => $post_thumbnail_id, 'alt' => $alt );
269
  }
270
 
271
  /**
@@ -328,15 +356,18 @@ function get_the_image_by_attachment( $args = array() ) {
328
  /* Get the attachment image. */
329
  $image = wp_get_attachment_image_src( $attachment_id, $args['size'] );
330
 
331
- /* Get the attachment excerpt. */
332
- $alt = trim( strip_tags( get_post_field( 'post_excerpt', $attachment_id ) ) );
 
 
 
333
 
334
  /* Save the attachment as the 'featured image'. */
335
  if ( true === $args['thumbnail_id_save'] )
336
  set_post_thumbnail( $args['post_id'], $attachment_id );
337
 
338
  /* Return the image URL. */
339
- return array( 'src' => $image[0], 'alt' => $alt );
340
  }
341
 
342
  /* Return false for anything else. */
@@ -397,7 +428,7 @@ function get_the_image_format( $args = array(), $image = false ) {
397
  extract( $args );
398
 
399
  /* If there is alt text, set it. Otherwise, default to the post title. */
400
- $image_alt = ( ( !empty( $image['alt'] ) ) ? $image['alt'] : apply_filters( 'the_title', get_post_field( 'post_title', $post_id ) ) );
401
 
402
  /* If there is a width or height, set them as HMTL-ready attributes. */
403
  $width = ( ( $width ) ? ' width="' . esc_attr( $width ) . '"' : '' );
@@ -406,12 +437,21 @@ function get_the_image_format( $args = array(), $image = false ) {
406
  /* Loop through the custom field keys and add them as classes. */
407
  if ( is_array( $meta_key ) ) {
408
  foreach ( $meta_key as $key )
409
- $classes[] = sanitize_html_class( $key );
410
  }
411
 
412
- /* Add the $size and any user-added $image_class to the class. */
413
- $classes[] = sanitize_html_class( $size );
414
- $classes[] = sanitize_html_class( $image_class );
 
 
 
 
 
 
 
 
 
415
 
416
  /* Join all the classes into a single string and make sure there are no duplicates. */
417
  $class = join( ' ', array_unique( $classes ) );
@@ -421,12 +461,16 @@ function get_the_image_format( $args = array(), $image = false ) {
421
 
422
  /* If $link_to_post is set to true, link the image to its post. */
423
  if ( $link_to_post )
424
- $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( apply_filters( 'the_title', get_post_field( 'post_title', $post_id ) ) ) . '">' . $html . '</a>';
425
 
426
  /* If there is a $post_thumbnail_id, apply the WP filters normally associated with get_the_post_thumbnail(). */
427
  if ( !empty( $image['post_thumbnail_id'] ) )
428
  $html = apply_filters( 'post_thumbnail_html', $html, $post_id, $image['post_thumbnail_id'], $size, '' );
429
 
 
 
 
 
430
  return $html;
431
  }
432
 
2
  /**
3
  * Plugin Name: Get The Image
4
  * Plugin URI: http://themehybrid.com/plugins/get-the-image
5
+ * Description: This is a highly intuitive script that can grab an image by custom field, featured image, post attachment, or extracting it from the post's content.
6
+ * Version: 0.9.0
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
+ */
10
+
11
+ /**
12
  * Get the Image - An advanced post image script for WordPress.
13
  *
14
  * Get the Image was created to be a highly-intuitive image script that displays post-specific images (an
25
  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26
  *
27
  * @package GetTheImage
28
+ * @version 0.9.0
29
  * @author Justin Tadlock <justin@justintadlock.com>
30
+ * @copyright Copyright (c) 2008 - 2013, Justin Tadlock
31
  * @link http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin
32
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
33
  */
56
  * @return string|array The HTML for the image. | Image attributes in an array.
57
  */
58
  function get_the_image( $args = array() ) {
59
+ global $_wp_additional_image_sizes;
60
 
61
  /* Set the default arguments. */
62
  $defaults = array(
63
+
64
+ /* Post the image is associated with. */
65
  'post_id' => get_the_ID(),
66
+
67
+ /* Methods of getting an image (in order). */
68
+ 'meta_key' => array( 'Thumbnail', 'thumbnail' ), // array|string
69
+ 'the_post_thumbnail' => true,
70
  'attachment' => true,
71
+ 'image_scan' => false,
72
+ 'callback' => null,
73
  'default_image' => false,
74
+
75
+ /* Attachment-specific arguments. */
76
+ 'size' => isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : 'thumbnail',
77
  'order_of_image' => 1,
78
+
79
+ /* Format/display of image. */
80
  'link_to_post' => true,
81
  'image_class' => false,
 
82
  'width' => false,
83
  'height' => false,
84
+ 'before' => '',
85
+ 'after' => '',
86
+
87
+ /* Captions. */
88
+ 'caption' => false, // Default WP [caption] requires a width.
89
+
90
+ /* Saving the image. */
91
  'meta_key_save' => false,
92
  'thumbnail_id_save' => false, // Set 'featured image'.
 
93
  'cache' => true,
94
+
95
+ /* Return/echo image. */
96
+ 'format' => 'img',
97
  'echo' => true,
98
+
99
+ /* Deprecated arguments. */
100
  'custom_key' => null, // @deprecated 0.6. Use 'meta_key'.
101
  'default_size' => null, // @deprecated 0.5. Use 'size'.
102
  );
107
  /* Merge the input arguments and the defaults. */
108
  $args = wp_parse_args( $args, $defaults );
109
 
110
+ /* If no post ID, return. */
111
+ if ( empty( $args['post_id'] ) )
112
+ return false;
113
+
114
  /* If $default_size is given, overwrite $size. */
115
  if ( !is_null( $args['default_size'] ) )
116
  $args['size'] = $args['default_size']; // Deprecated 0.5 in favor of $size
196
  $out = array();
197
 
198
  /* Get the image attributes. */
199
+ $atts = wp_kses_hair( $image_html, array( 'http', 'https' ) );
200
 
201
  /* Loop through the image attributes and add them in key/value pairs for the return array. */
202
  foreach ( $atts as $att )
203
  $out[ $att['name'] ] = $att['value'];
204
 
205
+ if ( !empty( $out['src'] ) )
206
+ $out['url'] = $out['src']; // @deprecated 0.5 Use 'src' instead of 'url'.
207
 
208
  /* Return the array of attributes. */
209
  return $out;
286
  /* Get the attachment image source. This should return an array. */
287
  $image = wp_get_attachment_image_src( $post_thumbnail_id, $size );
288
 
289
+ /* Get the attachment alt text. */
290
+ $alt = trim( strip_tags( get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ) ) );
291
+
292
+ /* Get the attachment caption. */
293
+ $caption = get_post_field( 'post_excerpt', $post_thumbnail_id );
294
 
295
  /* Return both the image URL and the post thumbnail ID. */
296
+ return array( 'src' => $image[0], 'post_thumbnail_id' => $post_thumbnail_id, 'alt' => $alt, 'caption' => $caption );
297
  }
298
 
299
  /**
356
  /* Get the attachment image. */
357
  $image = wp_get_attachment_image_src( $attachment_id, $args['size'] );
358
 
359
+ /* Get the attachment alt text. */
360
+ $alt = trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) );
361
+
362
+ /* Get the attachment caption. */
363
+ $caption = get_post_field( 'post_excerpt', $attachment_id );
364
 
365
  /* Save the attachment as the 'featured image'. */
366
  if ( true === $args['thumbnail_id_save'] )
367
  set_post_thumbnail( $args['post_id'], $attachment_id );
368
 
369
  /* Return the image URL. */
370
+ return array( 'src' => $image[0], 'alt' => $alt, 'caption' => $caption );
371
  }
372
 
373
  /* Return false for anything else. */
428
  extract( $args );
429
 
430
  /* If there is alt text, set it. Otherwise, default to the post title. */
431
+ $image_alt = ( ( !empty( $image['alt'] ) ) ? $image['alt'] : get_post_field( 'post_title', $post_id ) );
432
 
433
  /* If there is a width or height, set them as HMTL-ready attributes. */
434
  $width = ( ( $width ) ? ' width="' . esc_attr( $width ) . '"' : '' );
437
  /* Loop through the custom field keys and add them as classes. */
438
  if ( is_array( $meta_key ) ) {
439
  foreach ( $meta_key as $key )
440
+ $classes[] = $key;
441
  }
442
 
443
+ /* Add the $size to the class. */
444
+ $classes[] = $size;
445
+
446
+ /* Get the custom image class. */
447
+ if ( !empty( $image_class ) ) {
448
+ if ( !is_array( $image_class ) )
449
+ $image_class = preg_split( '#\s+#', $image_class );
450
+ $classes = array_merge( $classes, $image_class );
451
+ }
452
+
453
+ /* Sanitize all the classes. */
454
+ $classes = array_map( 'sanitize_html_class', $classes );
455
 
456
  /* Join all the classes into a single string and make sure there are no duplicates. */
457
  $class = join( ' ', array_unique( $classes ) );
461
 
462
  /* If $link_to_post is set to true, link the image to its post. */
463
  if ( $link_to_post )
464
+ $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
465
 
466
  /* If there is a $post_thumbnail_id, apply the WP filters normally associated with get_the_post_thumbnail(). */
467
  if ( !empty( $image['post_thumbnail_id'] ) )
468
  $html = apply_filters( 'post_thumbnail_html', $html, $post_id, $image['post_thumbnail_id'], $size, '' );
469
 
470
+ /* If we're showing a caption. */
471
+ if ( true === $args['caption'] && !empty( $image['caption'] ) )
472
+ $html = img_caption_shortcode( array( 'caption' => $image['caption'], 'width' => $args['width'] ), $html );
473
+
474
  return $html;
475
  }
476
 
readme.css DELETED
@@ -1,77 +0,0 @@
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 {
12
- color: #2f6eb9;
13
- text-decoration: none;
14
- }
15
- a:hover, a:active {
16
- text-decoration: underline;
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
- h3 {
26
- font-weight: normal;
27
- font-style: italic;
28
- font-family: Georgia, Times, 'Times New Roman', serif;
29
- }
30
- h1 {
31
- margin-top: 80px;
32
- font-size: 2.2em;
33
- }
34
- code {
35
- padding: 0 3px;
36
- background: #eee;
37
- }
38
- pre code {
39
- padding: 0;
40
- }
41
- pre {
42
- padding: 9px;
43
- background: #eee;
44
- border: 1px solid #ccc;
45
- }
46
- ul {
47
- list-style: square;
48
- }
49
- p.first {
50
- font-size: 21px;
51
- }
52
- p.second {
53
- font-size: 15px;
54
- }
55
- ul.space li {
56
- margin-bottom: 10px;
57
- }
58
- .section {
59
- overflow: hidden;
60
- }
61
-
62
- .columns-2 {
63
- float: left;
64
- width: 350px;
65
- margin: 0 0 21px 25px;
66
- }
67
- .columns-3 {
68
- float: left;
69
- width: 230px;
70
- margin: 0 0 21px 20px;
71
- }
72
- /* Warnings/Alerts */
73
- .warning, .alert {
74
- padding: 6px 9px;
75
- background: #fffbbc;
76
- border: 1px solid #E6DB55;
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.html DELETED
@@ -1,220 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
5
- <title>A guide to the Get the Image plugin</title>
6
-
7
- <link rel="stylesheet" href="readme.css" type="text/css" media="screen" />
8
-
9
- </head>
10
- <body>
11
-
12
- <h1>A guide to Get the Image</h1>
13
-
14
- <p class="first"><em>Get the Image</em> is a plugin that grabs images for you. It was designed to make the process of things such as adding thumbnails, feature images, and/or other images to your blog much easier, but it's so much more than that. It is an image-based representation of your WordPress posts.</p>
15
-
16
- <p class="second">To use this plugin, you must be familiar with two very important things in WordPress: the <a href="http://codex.wordpress.org/Template_Hierarchy" title="Template Hierarchy">Template Hierarchy</a> and <a href="http://codex.wordpress.org/The_Loop" title="The Loop">The Loop</a>. If you don't have a working knowledge of those two things, then you should not attempt to use this plugin. More importantly, you should be familiar with how all of this works within your theme because not all themes are the same.</p>
17
-
18
- <h2>What this plugin does</h2>
19
-
20
- <p>This plugin was made to easily find images and add them on pages where the full post isn't shown. This is the order in which the plugin attempts to grab an image.</p>
21
-
22
- <ol>
23
- <li>Looks for an image by custom field.</li>
24
- <li>If no image is added by custom field, check for a <a href="http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature" title="WordPress 2.9's post image feature">post image</a> (WordPresss 2.9+ feature).</li>
25
- <li>If no image is found, it grabs an image attached to your post.</li>
26
- <li>If no image is attached, it can extract an image from your post content (off by default).</li>
27
- <li>If no image is found, checks for a custom callback function that developers may optionally set.</li>
28
- <li>If no image is found at this point, it will default to an image you set (not set by default).</li>
29
- </ol>
30
-
31
- <h2>How to install the plugin</h2>
32
-
33
- <ol>
34
- <li>Uzip the <code>get-the-image.zip</code> folder.</li>
35
- <li>Upload the <code>get-the-image</code> folder to your <code>/wp-content/plugins</code> directory.</li>
36
- <li>In your WordPress dashboard, head over to the <em>Plugins</em> section.</li>
37
- <li>Activate <em>Get The Image</em>.</li>
38
- </ol>
39
-
40
- <h2>How to use the plugin</h2>
41
-
42
- <p>To call the image script, you'll need to use what's called <a href="http://codex.wordpress.org/Template_Tags/How_to_Pass_Tag_Parameters#Tags_with_PHP_function-style_parameters" title="PHP function-style parameters">function-style parameters</a>.</p>
43
-
44
- <p><strong>Example with function-style parameters</strong></p>
45
-
46
- <pre><code>&lt;?php get_the_image( array( 'meta_key' => array( 'Thumbnail', 'thumbnail' ), 'size' => 'thumbnail' ) ); ?></code></pre>
47
-
48
- <h2>The image script parameters</h2>
49
-
50
- <p>By simply making a function call to <code>&lt;?php get_the_image(); ?></code> within a template file, the script will default to this:</p>
51
-
52
- <pre><code>$defaults = array(
53
- 'meta_key' => array( 'Thumbnail', 'thumbnail' ), // array|string
54
- 'post_id' => get_the_ID(),
55
- 'attachment' => true,
56
- 'the_post_thumbnail' => true, // WP 2.9+ image function
57
- 'size' => 'thumbnail',
58
- 'default_image' => false,
59
- 'order_of_image' => 1,
60
- 'link_to_post' => true,
61
- 'image_class' => false,
62
- 'image_scan' => false,
63
- 'width' => false,
64
- 'height' => false,
65
- 'format' => 'img',
66
- 'meta_key_save' => false,
67
- 'thumbnail_id_save' => false, // Set 'featured image'.
68
- 'callback' => null,
69
- 'cache' => true,
70
- 'before' => '',
71
- 'after' => '',
72
- 'echo' => true,
73
- 'custom_key' => null, // @deprecated 0.6. Use 'meta_key'.
74
- 'default_size' => null, // @deprecated 0.5. Use 'size'.
75
- );</code></pre>
76
-
77
- <dl>
78
- <dt>meta_key</dt>
79
- <dd>This parameter refers to post meta keys (custom fields) that you use. Remember, meta keys are case-sensitive (defaults are <code>Thumbnail</code> and <code>thumbnail</code>). By default, this is an array of meta keys, but it can also be a string for a single meta key.</dd>
80
- <dt>post_id</dt>
81
- <dd>The ID of the post to get the image for. This defaults to the current post in the loop.</dd>
82
- <dt>attachment</dt>
83
- <dd>The script will look for images attached to the post (set to <code>true</code> by default).</dd>
84
- <dt>the_post_thumbnail</dt>
85
- <dd>This refers to the WordPress 2.9's new <code>the_post_thumbnail()</code> feature. By having this set to <code>true</code>, you may select an image from the post image meta box while in the post editor.</dd>
86
- <dt>size</dt>
87
- <dd>This refers to the size of an attached image. You can choose between <code>thumbnail</code>, <code>medium</code>, <code>large</code>, <code>full</code>, or any custom image size you have available (the default is <code>thumbnail</code>).</dd>
88
- <dt>default_image</dt>
89
- <dd>Will take the input of an image URL and use it if no other images are found (no default set).</dd>
90
- <dt>order_of_image</dt>
91
- <dd>You can choose for the script to grab something other than the first attached image. This only refers to image attachments.</dd>
92
- <dt>link_to_post</dt>
93
- <dd>Whether the image shown should be linked to the post (set to <code>true</code> by default).</dd>
94
- <dt>image_class</dt>
95
- <dd>You can give an additional class to the image for use in your CSS.</dd>
96
- <dt>image_scan</dt>
97
- <dd>If set to <code>true</code>, the script will search within your post for an image that's been added.</dd>
98
- <dt>width</dt>
99
- <dd>Set the width of the image on output.</dd>
100
- <dt>height</dt>
101
- <dd>Set the height of the image on output.</dd>
102
- <dt>format</dt>
103
- <dd>What format to return the image in. If set to <code>array</code> the return value of the function will be an array of <code>&lt;img></code> attributes. All other values will return the <code>&lt;img></code> element.</dd>
104
- <dt>meta_key_save</dt>
105
- <dd>A meta key to save the image <acronym title="Uniform Resource Locator">URL</acronym> as. This is useful if you're not using custom fields but want to cut back on database queries by having the script automatically set the custom field for you. By default, this is set to <code>false</code>.</dd>
106
- <dt>thumbnail_id_save</dt>
107
- <dd>Whether to save the attachment ID as the post thumbnail (featured image) ID if no featured image is set for the post. By default, this is set to <code>false</code></dd>
108
- <dt>callback</dt>
109
- <dd>A custom callback function that will be called if set. It's only called if no images are found by any other options of the plugin. However, it will be run before the <code>default_image</code> is set. The <code>$args</code> array is passed to the callback function as the only parameter.</dd>
110
- <dt>cache</dt>
111
- <dd>Whether to use the WordPress Cache <acronym title="Application Programming Interface">API</acronym> (integrates with caching plugins) to serve the post images. By default, this is set to <code>true</code>.</dd>
112
- <dt>before</dt>
113
- <dd><abbr title="Hypertext Markup Language">HTML</abbr> to place before the output of the image.</dd>
114
- <dt>after</dt>
115
- <dd><abbr title="Hypertext Markup Language">HTML</abbr> to place after the output of the image.</dd>
116
- <dt>echo</dt>
117
- <dd>If set to <code>true</code>, the image is shown on the page. If set to <code>false</code>, the image will be returned to use in your own function. (Set to <code>true</code> by default.)</dd>
118
- </dl>
119
-
120
- <h2>Some examples of how to use this plugin</h2>
121
-
122
- <p><strong>Example 1:</strong> Let's suppose that you want to add thumbnails to your category archive pages. What you'll need to do is open your <code>category.php</code> file and add this code within the Loop:</p>
123
-
124
- <pre><code>&lt;?php get_the_image(); ?></code></pre>
125
-
126
- <p>By default, that will look for an image with the custom field <strong>key</strong> <code>Thumbnail</code> and <code>thumnbail</code>. If that image doesn't exist, it will check if a post image has been set. If that image doesn't exist, it will search for any images attached to your post.</p>
127
-
128
- <p><strong>Example 2:</strong> Let's suppose you want a full-sized image and maybe you want to grab it by a custom field key of <code>Feature</code>. Depending on your theme, this will need to go within the Loop in whatever file is calling the featured article.</p>
129
-
130
- <pre><code>&lt;?php get_the_image( array( 'meta_key' => 'Feature', 'size' => 'full' ) ); ?></code></pre>
131
-
132
- <p>If no feature image exists by custom field, it will look for images attached to your post.</p>
133
-
134
- <p><strong>Example 3:</strong> If you want to have a sort of fallback image, then you can set an image for the script to default to if no other images are found.</p>
135
-
136
- <pre><code>&lt;?php get_the_image( array( 'default_image' => 'http://mysite.com/wp-content/uploads/example.jpg' ) ); ?></code></pre>
137
-
138
- <p><strong>Example 4:</strong> You can even make the script scan for images that have been added to your post with this:</p>
139
-
140
- <pre><code>&lt;?php get_the_image( array( 'image_scan' => true ) ); ?></code></pre>
141
-
142
- <p><strong>Example 5:</strong> You might want to make the script grab the second attached image to a post. You can do that with this code:</p>
143
-
144
- <pre><code>&lt;?php get_the_image( array( 'order_of_image' => 2 ) ); ?></code></pre>
145
-
146
- <p><strong>Example 6:</strong> Saving an image to the <code>Thumbnail</code> custom field automatically.</p>
147
-
148
- <pre><code>&lt;?php get_the_image( array( 'meta_key_save' => 'Thumbnail' ) ); ?></code></pre>
149
-
150
- <h2>A real-world example</h2>
151
-
152
- <p>This is an example Loop, which may differ slightly from your theme, but the concept is the same. The call to get the image can go anywhere between the opening and closing lines.</p>
153
-
154
- <pre><code>&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
155
-
156
- &lt;div id="post-&lt;?php the_ID(); ?>" &lt;?php post_class(); ?>>
157
-
158
- &lt;?php get_the_image( array( 'meta_key' => 'feature_img', 'size' => 'medium', 'width' => '200', 'height' => '200', 'image_class' => 'feature' ) ); ?>
159
-
160
- &lt;h2>&lt;a href="&lt;?php the_permalink(); ?>" title="&lt;?php the_title_attribute(); ?>" rel="bookmark">&lt;?php the_title(); ?>&lt;/a>&lt;/h2>
161
-
162
- &lt;div class="entry-summary">
163
- &lt;?the_excerpt(); ?>
164
- &lt;/div>
165
-
166
- &lt;/div>
167
-
168
- &lt;?php endwhile; endif; ?></code></pre>
169
-
170
- <h2>Protect yourself from errors in the future</h2>
171
-
172
- <p>Sometimes, we stop using plugins, but we forget to remove the function calls to the plugin in our theme files. When deactivated, this causes errors. To protect yourself from these errors, you can call the image script like this:</p>
173
-
174
- <pre><code>&lt;?php if ( function_exists( 'get_the_image' ) ) { get_the_image(); } ?></code></pre>
175
-
176
- <p>Basically, this just checks to see if the plugin is activated and has loaded the appropriate function.</p>
177
-
178
- <h2>Styling your images</h2>
179
-
180
- <p>The plugin will help you style your images by giving you some CSS classes to work with. It will turn your custom field keys and default size into CSS classes. You can also choose to input your own class.</p>
181
-
182
- <p>By default, you can add this to your CSS:</p>
183
-
184
- <pre><code>img.thumbnail { }</code></pre>
185
-
186
- <p>Let's suppose you've used this code:</p>
187
-
188
- <pre><code>&lt;?php get_the_image( array( 'meta_key' => array( 'Donkey Kong', 'mario' ), 'size' => 'full' ) ); ?></code></pre>
189
-
190
- <p>This will give you these CSS classes to work with:</p>
191
-
192
- <pre><code>img.full { }
193
- img.donkey-kong { }
194
- img.mario { }</code></pre>
195
-
196
- <p>You can also input a custom CSS class like so:</p>
197
-
198
- <pre><code>&lt;?php get_the_image( array( 'image_class' => 'custom-image' ) ); ?></code></pre>
199
-
200
- <p>You will still have the <code>size</code> and <code>custom_key</code> classes plus your additional class:</p>
201
-
202
- <pre><code>img.custom-image { }
203
- img.thumbnail { }</code></pre>
204
-
205
- <h2>Plugin support</h2>
206
-
207
- <p>I run a WordPress community called <a href="http://themehybrid.com" title="Theme Hybrid">Theme Hybrid</a>, which is where I fully support all of my WordPress projects, including plugins. You can sign up for an account to get plugin support for a small yearly fee ($29 <acronym title="United States Dollars">USD</acronym> at the time of writing).</p>
208
-
209
- <p>I know. I know. You might not want to pay for support, but just consider it a donation to the project. To continue making cool, GPL-licensed plugins and having the time to support them, I must pay the bills.</p>
210
-
211
- <h2>Copyright &amp; license</h2>
212
-
213
- <p><em>Get the Image</em> is licensed under the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" title="GNU GPL">GNU General Public License</a>, version 2 (<acronym title="GNU General Public License">GPL</acronym>).</p>
214
-
215
- <p>This plugin is copyrighted to <a href="http://justintadlock.com" title="Justin Tadlock">Justin Tadlock</a>.</p>
216
-
217
- <p>2008&thinsp;&ndash;&thinsp;2012 &copy; Justin Tadlock..</p>
218
-
219
- </body>
220
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.md ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Get the Image #
2
+
3
+ Get the Image is a plugin that grabs images for you. It was designed to make the process of things such as adding thumbnails, feature images, and/or other images to your blog much easier, but it's so much more than that. It is an image-based representation of your WordPress posts.
4
+
5
+ ## What the plugin does ##
6
+
7
+ This plugin was made to easily get an image related to a post. This is the method order in which the plugin attempts to grab an image.
8
+
9
+ * Meta key (custom field).
10
+ * Post thumbnail (WP featured image).
11
+ * Image attachment.
12
+ * Image embedded in the post content.
13
+ * Default/fallback image.
14
+
15
+ ## Usage ##
16
+
17
+ The basic function call for the plugin is like so:
18
+
19
+ <?php get_the_image(); ?>
20
+
21
+ This is the only function you should use from the plugin. It expects to be called within the WordPress posts loop unless you pass it a post ID directly (`post_id` argument).
22
+
23
+ To do more with the image script, you'll need to use what's called [function-style parameters](http://codex.wordpress.org/Template_Tags/How_to_Pass_Tag_Parameters#Tags_with_PHP_function-style_parameters). The following is a basic example of using function-style parameters.
24
+
25
+ <?php get_the_image( array( 'meta_key' => 'thumbnail', 'size' => 'thumbnail' ) ); ?>
26
+
27
+ ### Parameters ###
28
+
29
+ The `get_the_image()` function accepts a single parameter of `$args`, which is an array of parameters for deciding how to load an image. The following is the list of all the default arguments.
30
+
31
+ $defaults = array(
32
+
33
+ /* Post the image is associated with. */
34
+ 'post_id' => get_the_ID(),
35
+
36
+ /* Methods of getting an image (in order). */
37
+ 'meta_key' => array( 'Thumbnail', 'thumbnail' ), // array|string
38
+ 'the_post_thumbnail' => true,
39
+ 'attachment' => true,
40
+ 'image_scan' => false,
41
+ 'callback' => null,
42
+ 'default_image' => false,
43
+
44
+ /* Attachment-specific arguments. */
45
+ 'size' => isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : 'thumbnail',
46
+ 'order_of_image' => 1,
47
+
48
+ /* Format/display of image. */
49
+ 'link_to_post' => true,
50
+ 'image_class' => false,
51
+ 'width' => false,
52
+ 'height' => false,
53
+ 'before' => '',
54
+ 'after' => '',
55
+
56
+ /* Captions. */
57
+ 'caption' => false, // Default WP [caption] requires a width.
58
+
59
+ /* Saving the image. */
60
+ 'meta_key_save' => false,
61
+ 'thumbnail_id_save' => false, // Set 'featured image'.
62
+ 'cache' => true,
63
+
64
+ /* Return/echo image. */
65
+ 'format' => 'img',
66
+ 'echo' => true,
67
+
68
+ /* Deprecated arguments. */
69
+ 'custom_key' => null, // @deprecated 0.6. Use 'meta_key'.
70
+ 'default_size' => null, // @deprecated 0.5. Use 'size'.
71
+ );
72
+
73
+ * `post_id` - The ID of the post to get the image for. This defaults to the current post in the loop.
74
+ * `meta_key` - This parameter refers to post meta keys (custom fields) that you use. Remember, meta keys are case-sensitive (defaults are `Thumbnail` and `thumbnail`). By default, this is an array of meta keys, but it can also be a string for a single meta key.
75
+ * `attachment` - The script will look for images attached to the post (set to `true` by default).
76
+ * `the_post_thumbnail` - This refers to the `the_post_thumbnail()` WordPress function. By having this set to `true`, you may select an image from the featured image meta box while on the edit post screen.
77
+ * `size` - This refers to the size of an attached image. You can choose between `thumbnail`, `medium`, `large`, `full`, or any custom image size you have available (the default is `thumbnail`).
78
+ * `default_image` - Will take the input of an image URL and use it if no other images are found (no default set).
79
+ * `order_of_image` - You can choose for the script to grab something other than the first attached image. This only refers to image attachments.
80
+ * `link_to_post` - Whether the image shown should be linked to the post (set to `true` by default).
81
+ * `image_class` - You can give an additional class to the image for use in your CSS.
82
+ * `image_scan` - If set to `true`, the script will search within your post for an image that's been added.
83
+ * `width` - Set the width of the image on output.
84
+ * `height` - Set the height of the image on output.
85
+ * `format` - What format to return the image in. If set to `array` the return value of the function will be an array of `<img>` attributes. All other values will return the `<img>` element.
86
+ * `meta_key_save` - A meta key to save the image URL as. This is useful if you're not using custom fields but want to cut back on database queries by having the script automatically set the custom field for you. By default, this is set to `false`.
87
+ * `thumbnail_id_save` - Whether to save the attachment ID as the post thumbnail (featured image) ID if no featured image is set for the post. By default, this is set to `false`
88
+ * `callback` - A custom callback function that will be called if set. It's only called if no images are found by any other options of the plugin. However, it will be run before the `default_image` is set. The `$args` array is passed to the callback function as the only parameter.
89
+ * `cache` - Whether to use the WordPress Cache API (integrates with caching plugins) to serve the post images. By default, this is set to `true`.
90
+ * `before` - HTML to place before the output of the image.
91
+ * `after` - HTML to place after the output of the image.
92
+ * `echo` - If set to `true`, the image is shown on the page. If set to `false`, the image will be returned to use in your own function. (Set to `true` by default.)
93
+
94
+ ### Some usage examples ##
95
+
96
+ #### Example 1 ####
97
+
98
+ Let's suppose that you want to add thumbnails to your category archive pages. What you'll need to do is open your `category.php` file and add this code within the Loop:
99
+
100
+ <?php get_the_image(); ?>
101
+
102
+ By default, that will look for an image with the custom field **key** `Thumbnail` and `thumbnail`. If that image doesn't exist, it will check if a post image has been set. If that image doesn't exist, it will search for any images attached to your post.
103
+
104
+ #### Example 2 ####
105
+
106
+ Let's suppose you want a full-sized image and maybe you want to grab it by a custom field key of `Feature`. Depending on your theme, this will need to go within the Loop in whatever file is calling the featured article.
107
+
108
+ <?php get_the_image( array( 'meta_key' => 'Feature', 'size' => 'full' ) ); ?>
109
+
110
+ If no feature image exists by custom field, it will look for images attached to your post.
111
+
112
+ #### Example 3 ####
113
+
114
+ If you want to have a sort of fallback image, then you can set an image for the script to default to if no other images are found.
115
+
116
+ <?php get_the_image( array( 'default_image' => 'http://mysite.com/wp-content/uploads/example.jpg' ) ); ?>
117
+
118
+ #### Example 4 ####
119
+
120
+ You can even make the script scan for images that have been added to your post with this:
121
+
122
+ <?php get_the_image( array( 'image_scan' => true ) ); ?>
123
+
124
+ #### Example 5 ####
125
+
126
+ Saving an image to the `Thumbnail` custom field automatically.
127
+
128
+ <?php get_the_image( array( 'meta_key_save' => 'Thumbnail' ) ); ?>
129
+
130
+ ### A real-world example ###
131
+
132
+ This is an example Loop, which may differ slightly from your theme, but the concept is the same. The call to get the image can go anywhere between the opening and closing lines.
133
+
134
+ <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
135
+
136
+ <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
137
+
138
+ <?php get_the_image( array( 'meta_key' => 'feature_img', 'size' => 'medium', 'width' => '200', 'height' => '200', 'image_class' => 'feature' ) ); ?>
139
+
140
+ <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
141
+
142
+ <div class="entry-summary">
143
+ <?the_excerpt(); ?>
144
+ </div>
145
+
146
+ </div>
147
+
148
+ <?php endwhile; endif; ?>
149
+
150
+ ### Protect yourself from errors in the future ###
151
+
152
+ Sometimes, we stop using plugins, but we forget to remove the function calls to the plugin in our theme files. When deactivated, this causes errors. To protect yourself from these errors, you can call the image script like this:
153
+
154
+ <?php if ( function_exists( 'get_the_image' ) ) {
155
+ get_the_image();
156
+ } ?>
157
+
158
+ Basically, this just checks to see if the plugin is activated and has loaded the appropriate function.
159
+
160
+ ## Styling your images ##
161
+
162
+ The plugin will help you style your images by giving you some CSS classes to work with. It will turn your custom field keys and default size into CSS classes. You can also choose to input your own class.
163
+
164
+ By default, you can add this to your CSS:
165
+
166
+ img.thumbnail { }
167
+
168
+ Let's suppose you've used this code:
169
+
170
+ <?php get_the_image( array( 'meta_key' => array( 'Donkey Kong', 'mario' ), 'size' => 'full' ) ); ?>
171
+
172
+ This will give you these CSS classes to work with:
173
+
174
+ img.full { }
175
+ img.donkey-kong { }
176
+ img.mario { }
177
+
178
+ You can also input a custom CSS class like so:
179
+
180
+ <?php get_the_image( array( 'image_class' => 'custom-image' ) ); ?>
181
+
182
+ You will still have the `size` and `meta_key` classes plus your additional class:
183
+
184
+ img.custom-image { }
185
+ img.thumbnail { }
186
+
187
+ ## Changelog ##
188
+
189
+ ### Version 0.9.0 ###
190
+
191
+ #### Enhancements:
192
+
193
+ * Caption support. FTW!
194
+ * Multiple image classes now allowed via the `image_class` argument.
195
+ * Use current theme's `post-thumbnail` as default image size if set via `set_post_thumbnail_size()`.
196
+
197
+ #### Bug fixes:
198
+
199
+ * Use the WordPress-saved attachment alt text for the image.
200
+ * Only add `$out['src']` if `$out['url']` is set when returning as an array.
201
+ * Allow `https` when returning as an array.
202
+ * Use the correct variable (`$attachment_id`) when getting an image via attachment.
203
+
204
+ ### Version 0.8.1 ###
205
+
206
+ * Use correct `$attachment_id` variable instead of `$id`.
207
+ * Pass full `$image` array to the `get_the_image_meta_key_save()` function so that it saves correctly.
208
+ * Only use `before` and `after` arguments if an image is found.
209
+ * General code formatting updated.
210
+
211
+ ### Version 0.8 ###
212
+
213
+ * Inline docs updates.
214
+ * Added the `before` argument to output HTML before the image.
215
+ * Added the `after` argument to output HTML after the image.
216
+ * Added the `thumbnail_id_save` argument to allow the attached image to be saved as the thumbnail/featured image.
217
+ * Get the post ID via `get_the_ID()` rather than the global `$post` object.
218
+ * Fixed debug notice with `$image_html`.
219
+ * Moved the `*_fetch_post_thumbnail_html` hooks into the main function and only fire them if displaying to the screen.
220
+ * Simplified the `meta_key` logic.
221
+ * Completely rewrote the `attachment` logic.
222
+ * Sanitize classes with `sanitize_html_class()`.
223
+
224
+ ### Version 0.7 ###
225
+
226
+ * Deprecated and replaced functions that lacked the `get_the_image_` prefix.
227
+ * New cache delete functions that delete when a post or post meta is updated.
228
+ * Fixed notice when `image_scan` was used.
229
+
230
+ ### Version 0.6.2 ###
231
+
232
+ * Updated the cache to save by post ID instead of a single object.
233
+ * Minor code adjustments.
234
+
235
+ ### Version 0.6.1 ###
236
+
237
+ * Updated inline documentation of the code.
238
+ * Smarter `meta_key` logic, which allows a single meta key or an array of keys to be used.
239
+ * Set `custom_key` and `default_size` to `null` by default since they're deprecated.
240
+
241
+ ### Version 0.6 ###
242
+
243
+ * Deprecated `custom_key` in favor of `meta_key`.
244
+ * Added the `meta_key_save` argument to allow users to save the image as a meta key/value pair.
245
+ * Added a `callback` argument to allow developers to create a custom callback function.
246
+ * Added a `cache` argument, which allows users to turn off caching.
247
+
248
+ ### Version 0.5 ###
249
+
250
+ * Added support for persistent-caching plugins.
251
+ * Switched the `default_size` argument to `size` to be more in line with the WordPress post thumbnail arguments, but `default_size` will still work.
252
+ * Now using `wp_kses_hair()` to extract image attributes when using the `array` value for `format`.
253
+ * Image `alt` text will now use the attachment description if one has been given rather than the post title.
254
+ * Updated the `readme.html` instructions for using the plugin.
255
+
256
+ ### Version 0.4 ###
257
+
258
+ * Dropped support for older versions of WordPress. Now only compatible with 2.9+.
259
+ * Added support for `the_post_thumbnail()`, which is WordPress 2.9's new image functionality.
260
+ * New function: `image_by_the_post_thumbnail()`.
261
+ * Documented more of the code, so the inline PHP doc is updated.
262
+ * Cleaned up some of the old legacy code that's no longer needed.
263
+
264
+ ### Version 0.3.3 ###
265
+
266
+ * General code cleanup
267
+ * Added the `get_the_image` filter hook.
268
+
269
+ ### Version 0.3.2 ###
270
+
271
+ * General code cleanup.
272
+ * More efficient and logical code.
273
+ * Beefed up the inline documentation so developers can better understand the code.
274
+ * Added a GPL license.txt file.
275
+
276
+ ### Version 0.3.1 ###
277
+
278
+ * Fixed the default image and image scan features.
279
+
280
+ ### Version 0.3 ###
281
+
282
+ * Changed methods of calling the image script.
283
+ * Added more parameters.
284
+
285
+ ## Support ##
286
+
287
+ I run a WordPress community called [Theme Hybrid](http://themehybrid.com), which is where I fully support all of my WordPress projects, including plugins. You can sign up for an account to get plugin support for a small yearly fee ($29 USD at the time of writing).
288
+
289
+ I know. I know. You might not want to pay for support, but just consider it a donation to the project. To continue making cool, GPL-licensed plugins and having the time to support them, I must pay the bills.
290
+
291
+ ## Copyright and License ##
292
+
293
+ Get the Image is licensed under the [GNU GPL](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html), version 2 or later.
294
+
295
+ 2008&thinsp;&ndash;&thinsp;2013 &copy; [Justin Tadlock](http://justintadlock.com).
296
+
297
+ *[API]: Application Programming Interface
298
+ *[CSS]: Cascading Style Sheets
299
+ *[FTW]: For The Win
300
+ *[GPL]: General Public License
301
+ *[HTML]: Hypertext Markup Language
302
+ *[URL]: Uniform Resource Locator
303
+ *[USD]: United States Dollars
readme.txt CHANGED
@@ -1,71 +1,101 @@
1
  === Get the Image ===
 
2
  Contributors: greenshady
3
  Donate link: http://themehybrid.com/donate
4
  Tags: image, images, thumbnail
5
- Requires at least: 3.2
6
- Tested up to: 3.5
7
- Stable tag: 0.8.1
 
 
8
 
9
- An easy-to-use image script for adding things such as thumbnails and feature images.
10
 
11
  == Description ==
12
 
13
- *Get the Image* is a plugin that grabs images for you. It was designed to make the process of things such as adding thumbnails, feature images, and/or other images to your blog much easier, but it's so much more than that. It is an image-based representation of your WordPress posts.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- This is a highly intuitive script that can grab an image by custom field input, WP's post image feature, post attachment, or extracting it from the post's content.
16
 
17
- Support for this plugin is handled on the Theme Hybrid <a href="http://themehybrid.com/support">support forums</a>.
 
 
18
 
19
  == Installation ==
20
 
21
  1. Upload `get-the-image` to the `/wp-content/plugins/` directory.
22
- 1. Activate the plugin through the 'Plugins' menu in WordPress.
23
- 1. Add the appropriate code to your template files as outlined in the `readme.html` file.
24
-
25
- More detailed instructions are included in the plugin's `readme.html` file. It is important to read through that file to properly understand all of the options and how the plugin works.
26
 
27
  == Frequently Asked Questions ==
28
 
29
- = Why was this plugin created? =
30
 
31
- Many magazine-type themes require a lot of work when inputting images to make them look good. This plugin was developed to make that process much easier for the end user. But, at the same time, it needed to be flexible enough to handle anything.
32
 
33
- Other scripts are bloated and offer odd solutions. This plugin uses the built-in methods of WordPress to create things such as feature images, thumbnails, galleries, or whatever.
34
 
35
- This plugin was created to be a lightweight solution to handle a very powerful need in the WordPress community.
36
-
37
- = How does it pull images? =
38
 
39
  1. Looks for an image by custom field (one of your choosing).
40
- 1. If no image is added by custom field, check for an image using `the_post_thumbnail()` (WordPress featured image).
41
- 1. If no image is found, it grabs an image attached to your post.
42
- 1. If no image is attached, it can extract an image from your post content (off by default).
43
- 1. If no image is found at this point, it will default to an image you set (not set by default).
44
 
45
- = How do I add it to my theme? =
46
 
47
- There are several methods, but in general, you would use this call:
48
 
49
- `
50
- <?php if ( function_exists( 'get_the_image' ) ) get_the_image(); ?>
51
- `
52
 
53
- To see all methods and options, refer to the `readme.html` file included with the theme download.
54
 
55
  == Screenshots ==
56
 
57
- You can view this plugin in action on my <a href="http://justintadlock.com" title="Justin Tadlock's blog">personal blog</a> (note the thumbnails).
 
 
58
 
59
  == Changelog ==
60
 
61
- **Version 0.8.1**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  * Use correct `$attachment_id` variable instead of `$id`.
64
  * Pass full `$image` array to the `get_the_image_meta_key_save()` function so that it saves correctly.
65
  * Only use `before` and `after` arguments if an image is found.
66
  * General code formatting updated.
67
 
68
- **Version 0.8**
69
 
70
  * Inline docs updates.
71
  * Added the `before` argument to output HTML before the image.
@@ -78,31 +108,31 @@ You can view this plugin in action on my <a href="http://justintadlock.com" titl
78
  * Completely rewrote the `attachment` logic.
79
  * Sanitize classes with `sanitize_html_class()`.
80
 
81
- **Version 0.7**
82
 
83
  * Deprecated and replaced functions that lacked the `get_the_image_` prefix.
84
  * New cache delete functions that delete when a post or post meta is updated.
85
  * Fixed notice when `image_scan` was used.
86
 
87
- **Version 0.6.2**
88
 
89
  * Updated the cache to save by post ID instead of a single object.
90
  * Minor code adjustments.
91
 
92
- **Version 0.6.1**
93
 
94
  * Updated inline documentation of the code.
95
  * Smarter `meta_key` logic, which allows a single meta key or an array of keys to be used.
96
  * Set `custom_key` and `default_size` to `null` by default since they're deprecated.
97
 
98
- **Version 0.6**
99
 
100
  * Deprecated `custom_key` in favor of `meta_key`.
101
  * Added the `meta_key_save` argument to allow users to save the image as a meta key/value pair.
102
  * Added a `callback` argument to allow developers to create a custom callback function.
103
  * Added a `cache` argument, which allows users to turn off caching.
104
 
105
- **Version 0.5**
106
 
107
  * Added support for persistent-caching plugins.
108
  * Switched the `default_size` argument to `size` to be more in line with the WordPress post thumbnail arguments, but `default_size` will still work.
@@ -110,7 +140,7 @@ You can view this plugin in action on my <a href="http://justintadlock.com" titl
110
  * Image `alt` text will now use the attachment description if one has been given rather than the post title.
111
  * Updated the `readme.html` instructions for using the plugin.
112
 
113
- **Version 0.4**
114
 
115
  * Dropped support for older versions of WordPress. Now only compatible with 2.9+.
116
  * Added support for `the_post_thumbnail()`, which is WordPress 2.9's new image functionality.
@@ -118,23 +148,23 @@ You can view this plugin in action on my <a href="http://justintadlock.com" titl
118
  * Documented more of the code, so the inline PHP doc is updated.
119
  * Cleaned up some of the old legacy code that's no longer needed.
120
 
121
- **Version 0.3.3**
122
 
123
  * General code cleanup
124
  * Added the `get_the_image` filter hook.
125
 
126
- **Version 0.3.2**
127
 
128
  * General code cleanup.
129
  * More efficient and logical code.
130
  * Beefed up the inline documentation so developers can better understand the code.
131
  * Added a GPL license.txt file.
132
 
133
- **Version 0.3.1**
134
 
135
  * Fixed the default image and image scan features.
136
 
137
- **Version 0.3**
138
 
139
  * Changed methods of calling the image script.
140
  * Added more parameters.
1
  === Get the Image ===
2
+
3
  Contributors: greenshady
4
  Donate link: http://themehybrid.com/donate
5
  Tags: image, images, thumbnail
6
+ Requires at least: 3.5
7
+ Tested up to: 3.7
8
+ Stable tag: 0.9.0
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
+ An easy-to-use image script for adding things such as thumbnail, slider, gallery, and feature images.
13
 
14
  == Description ==
15
 
16
+ Get the Image is one of the most advanced thumbnail/image scripts ever created for WordPress.
17
+
18
+ It is used everywhere from small blogs to large, enterprise-level solutions like [WordPress.com VIP](http://vip.wordpress.com/). Get the Image offers something for everybody. Much of the reason for its success is because it uses standard WordPress code and methods for doing what it needs to do, which is to simply grab images.
19
+
20
+ The plugin was designed to make the process of adding thumbnail, featured, slider, gallery, and other images to your blog much easier, but it's so much more than that. It is an image-based representation of your WordPress posts.
21
+
22
+ This is a highly intuitive script that can grab an image by custom field input, WordPress' featured image, post attachment, or extracting it from the post's content. Plus, a lot more!
23
+
24
+ ### A little history ###
25
+
26
+ The original plugin was in launched 2008, which means it has several years of solid testing and development behind it. It was created at a time when WordPress had very little native media support. At the time, it was mostly used as a "thumbnail" script for magazine-/news-style sites. But, it has grown into a much more flexible script over the years.
27
+
28
+ Even with WordPress' more recent advancements in image management, many users still continue using this plugin because it offers a more robust image script than core WordPress.
29
+
30
+ The plugin has been downloaded 100,000s of times and is used on millions of sites as part of WordPress theme packages.
31
 
32
+ Other image plugins have come and gone, but Get the Image has stood the test of time with several years of successful installs and happy users.
33
 
34
+ ### Professional support ###
35
+
36
+ If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](http://themehybrid.com/support), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 40,000+ users (and growing).
37
 
38
  == Installation ==
39
 
40
  1. Upload `get-the-image` to the `/wp-content/plugins/` directory.
41
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
42
+ 3. Add the appropriate code to your template files as outlined in the `readme.md` file.
 
 
43
 
44
  == Frequently Asked Questions ==
45
 
46
+ ### Why was this plugin created? ###
47
 
48
+ It was originally created to work with magazine/news themes. These types of themes typically required a lot of work when inputting images to make them look good. This plugin was developed to make that process much easier for the end user. But, at the same time, it needed to be flexible enough to handle anything.
49
 
50
+ However, over the years, it has grown to be one of the most robust image scripts for WordPress.
51
 
52
+ ### How does it grab images? ###
 
 
53
 
54
  1. Looks for an image by custom field (one of your choosing).
55
+ 2. If no image is added by custom field, check for an image using `the_post_thumbnail()` (WordPress featured image).
56
+ 3. If no image is found, it grabs an image attached to your post.
57
+ 4. If no image is attached, it can extract an image from your post content (off by default).
58
+ 5. If no image is found at this point, it will fall back to a default image (not set by default).
59
 
60
+ ### How do I add it to my theme? ###
61
 
62
+ There are several methods, but in general, you would use this call within The Loop.
63
 
64
+ <?php if ( function_exists( 'get_the_image' ) ) get_the_image(); ?>
 
 
65
 
66
+ To see all methods and options, refer to the `readme.md` file included with the plugin download.
67
 
68
  == Screenshots ==
69
 
70
+ 1. Slider plus thumbnails.
71
+ 2. Portfolio images.
72
+ 3. Gallery-style thumbnails.
73
 
74
  == Changelog ==
75
 
76
+ ### Version 0.9.0 ###
77
+
78
+ #### Enhancements: ####
79
+
80
+ * Caption support. FTW!
81
+ * Multiple image classes now allowed via the `image_class` argument.
82
+ * Use current theme's `post-thumbnail` as default image size if set via `set_post_thumbnail_size()`.
83
+
84
+ #### Bug fixes: ####
85
+
86
+ * Use the WordPress-saved attachment alt text for the image.
87
+ * Only add `$out['src']` if `$out['url']` is set when returning as an array.
88
+ * Allow `https` when returning as an array.
89
+ * Use the correct variable (`$attachment_id`) when getting an image via attachment.
90
+
91
+ ### Version 0.8.1 ###
92
 
93
  * Use correct `$attachment_id` variable instead of `$id`.
94
  * Pass full `$image` array to the `get_the_image_meta_key_save()` function so that it saves correctly.
95
  * Only use `before` and `after` arguments if an image is found.
96
  * General code formatting updated.
97
 
98
+ ### Version 0.8 ###
99
 
100
  * Inline docs updates.
101
  * Added the `before` argument to output HTML before the image.
108
  * Completely rewrote the `attachment` logic.
109
  * Sanitize classes with `sanitize_html_class()`.
110
 
111
+ ### Version 0.7 ###
112
 
113
  * Deprecated and replaced functions that lacked the `get_the_image_` prefix.
114
  * New cache delete functions that delete when a post or post meta is updated.
115
  * Fixed notice when `image_scan` was used.
116
 
117
+ ### Version 0.6.2 ###
118
 
119
  * Updated the cache to save by post ID instead of a single object.
120
  * Minor code adjustments.
121
 
122
+ ### Version 0.6.1 ###
123
 
124
  * Updated inline documentation of the code.
125
  * Smarter `meta_key` logic, which allows a single meta key or an array of keys to be used.
126
  * Set `custom_key` and `default_size` to `null` by default since they're deprecated.
127
 
128
+ ### Version 0.6 ###
129
 
130
  * Deprecated `custom_key` in favor of `meta_key`.
131
  * Added the `meta_key_save` argument to allow users to save the image as a meta key/value pair.
132
  * Added a `callback` argument to allow developers to create a custom callback function.
133
  * Added a `cache` argument, which allows users to turn off caching.
134
 
135
+ ### Version 0.5 ###
136
 
137
  * Added support for persistent-caching plugins.
138
  * Switched the `default_size` argument to `size` to be more in line with the WordPress post thumbnail arguments, but `default_size` will still work.
140
  * Image `alt` text will now use the attachment description if one has been given rather than the post title.
141
  * Updated the `readme.html` instructions for using the plugin.
142
 
143
+ ### Version 0.4 ###
144
 
145
  * Dropped support for older versions of WordPress. Now only compatible with 2.9+.
146
  * Added support for `the_post_thumbnail()`, which is WordPress 2.9's new image functionality.
148
  * Documented more of the code, so the inline PHP doc is updated.
149
  * Cleaned up some of the old legacy code that's no longer needed.
150
 
151
+ ### Version 0.3.3 ###
152
 
153
  * General code cleanup
154
  * Added the `get_the_image` filter hook.
155
 
156
+ ### Version 0.3.2 ###
157
 
158
  * General code cleanup.
159
  * More efficient and logical code.
160
  * Beefed up the inline documentation so developers can better understand the code.
161
  * Added a GPL license.txt file.
162
 
163
+ ### Version 0.3.1 ###
164
 
165
  * Fixed the default image and image scan features.
166
 
167
+ ### Version 0.3 ###
168
 
169
  * Changed methods of calling the image script.
170
  * Added more parameters.
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file