Multiple Post Thumbnails - Version 0.6

Version Description

  • Update get_the_post_thumbnail return filter to use format {$post_type}_{$thumb_id}_thumbnail_html which allows filtering by post type and thumbnail id which was the intent. Props gordonbrander.
  • Update plugin URL to point to Plugin Directory
Download this release

Release Info

Developer chrisscott
Plugin Icon wp plugin Multiple Post Thumbnails
Version 0.6
Comparing to
See all releases

Code changes from version 0.5 to 0.6

Files changed (2) hide show
  1. multi-post-thumbnails.php +10 -10
  2. readme.txt +15 -3
multi-post-thumbnails.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
3
  Plugin Name: Multiple Post Thumbnails
4
- Plugin URI: http://vocecommunications.com/
5
  Description: Adds the ability to add multiple post thumbnails to a post type.
6
- Version: 0.5
7
  Author: Chris Scott
8
  Author URI: http://vocecommuncations.com/
9
  */
@@ -167,21 +167,21 @@ if (!class_exists('MultiPostThumbnails')) {
167
  * Display Post Thumbnail.
168
  *
169
  * @param string $post_type The post type.
170
- * @param string $id The id used to register the thumbnail.
171
  * @param string $post_id Optional. Post ID.
172
  * @param int $size Optional. Image size. Defaults to 'post-thumbnail', which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );.
173
  * @param string|array $attr Optional. Query string or array of attributes.
174
  * @param bool $link_to_original Optional. Wrap link to original image around thumbnail?
175
  */
176
- public static function the_post_thumbnail($post_type, $id, $post_id = null, $size = 'post-thumbnail', $attr = '', $link_to_original = false) {
177
- echo self::get_the_post_thumbnail($post_type, $id, $post_id, $size, $attr, $link_to_original);
178
  }
179
 
180
  /**
181
  * Retrieve Post Thumbnail.
182
  *
183
  * @param string $post_type The post type.
184
- * @param string $id The id used to register the thumbnail.
185
  * @param int $post_id Optional. Post ID.
186
  * @param string $size Optional. Image size. Defaults to 'thumbnail'.
187
  * @param bool $link_to_original Optional. Wrap link to original image around thumbnail?
@@ -191,7 +191,7 @@ if (!class_exists('MultiPostThumbnails')) {
191
  global $id;
192
  $post_id = (NULL === $post_id) ? $id : $post_id;
193
  $post_thumbnail_id = self::get_post_thumbnail_id($post_type, $thumb_id, $post_id);
194
- $size = apply_filters("{$post_type}_{$id}_thumbnail_size", $size);
195
  if ($post_thumbnail_id) {
196
  do_action("begin_fetch_multi_{$post_type}_thumbnail_html", $post_id, $post_thumbnail_id, $size); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
197
  $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
@@ -199,12 +199,12 @@ if (!class_exists('MultiPostThumbnails')) {
199
  } else {
200
  $html = '';
201
  }
202
-
203
  if ($link_to_original) {
204
  $html = sprintf('<a href="%s">%s</a>', wp_get_attachment_url($post_thumbnail_id), $html);
205
  }
206
-
207
- return apply_filters("{$post_type}_{$id}_thumbnail_html", $html, $post_id, $post_thumbnail_id, $size, $attr);
208
  }
209
 
210
  /**
1
  <?php
2
  /*
3
  Plugin Name: Multiple Post Thumbnails
4
+ Plugin URI: http://wordpress.org/extend/plugins/multiple-post-thumbnails/
5
  Description: Adds the ability to add multiple post thumbnails to a post type.
6
+ Version: 0.6
7
  Author: Chris Scott
8
  Author URI: http://vocecommuncations.com/
9
  */
167
  * Display Post Thumbnail.
168
  *
169
  * @param string $post_type The post type.
170
+ * @param string $thumb_id The id used to register the thumbnail.
171
  * @param string $post_id Optional. Post ID.
172
  * @param int $size Optional. Image size. Defaults to 'post-thumbnail', which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );.
173
  * @param string|array $attr Optional. Query string or array of attributes.
174
  * @param bool $link_to_original Optional. Wrap link to original image around thumbnail?
175
  */
176
+ public static function the_post_thumbnail($post_type, $thumb_id, $post_id = null, $size = 'post-thumbnail', $attr = '', $link_to_original = false) {
177
+ echo self::get_the_post_thumbnail($post_type, $thumb_id, $post_id, $size, $attr, $link_to_original);
178
  }
179
 
180
  /**
181
  * Retrieve Post Thumbnail.
182
  *
183
  * @param string $post_type The post type.
184
+ * @param string $thumb_id The id used to register the thumbnail.
185
  * @param int $post_id Optional. Post ID.
186
  * @param string $size Optional. Image size. Defaults to 'thumbnail'.
187
  * @param bool $link_to_original Optional. Wrap link to original image around thumbnail?
191
  global $id;
192
  $post_id = (NULL === $post_id) ? $id : $post_id;
193
  $post_thumbnail_id = self::get_post_thumbnail_id($post_type, $thumb_id, $post_id);
194
+ $size = apply_filters("{$post_type}_{$post_id}_thumbnail_size", $size);
195
  if ($post_thumbnail_id) {
196
  do_action("begin_fetch_multi_{$post_type}_thumbnail_html", $post_id, $post_thumbnail_id, $size); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
197
  $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
199
  } else {
200
  $html = '';
201
  }
202
+
203
  if ($link_to_original) {
204
  $html = sprintf('<a href="%s">%s</a>', wp_get_attachment_url($post_thumbnail_id), $html);
205
  }
206
+
207
+ return apply_filters("{$post_type}_{$thumb_id}_thumbnail_html", $html, $post_id, $post_thumbnail_id, $size, $attr);
208
  }
209
 
210
  /**
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: chrisscott
3
  Tags: thumbnails, image
4
  Requires at least: 2.9.2
5
- Tested up to: 3.1
6
- Stable tag: 0.5
7
 
8
  Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
9
 
@@ -69,6 +69,13 @@ You can register multiple image sizes for a given thumbnail if desired.
69
 
70
  == Changelog ==
71
 
 
 
 
 
 
 
 
72
  = 0.4 =
73
  * Added: optional argument `$link_to_original` to *_the_post_thumbnails template tags. Thanks to gfors for the suggestion.
74
  * Fixed: PHP warning in media manager due to non-existent object
@@ -80,4 +87,9 @@ You can register multiple image sizes for a given thumbnail if desired.
80
  * Update docs and screenshots. Update tested through to 3.0 release.
81
 
82
  = 0.1 =
83
- * Initial release.
 
 
 
 
 
2
  Contributors: chrisscott
3
  Tags: thumbnails, image
4
  Requires at least: 2.9.2
5
+ Tested up to: 3.1.3
6
+ Stable tag: 0.6
7
 
8
  Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
9
 
69
 
70
  == Changelog ==
71
 
72
+ = 0.6 =
73
+ * Update `get_the_post_thumbnail` return filter to use format `{$post_type}_{$thumb_id}_thumbnail_html` which allows filtering by post type and thumbnail id which was the intent. Props gordonbrander.
74
+ * Update plugin URL to point to Plugin Directory
75
+
76
+ = 0.5 =
77
+ * Update readme to check for `MultiPostThumbnails` class before calling.
78
+
79
  = 0.4 =
80
  * Added: optional argument `$link_to_original` to *_the_post_thumbnails template tags. Thanks to gfors for the suggestion.
81
  * Fixed: PHP warning in media manager due to non-existent object
87
  * Update docs and screenshots. Update tested through to 3.0 release.
88
 
89
  = 0.1 =
90
+ * Initial release.
91
+
92
+ == Upgrade Notice ==
93
+
94
+ = 0.6 =
95
+ `get_the_post_thumbnail` return filter changed to use the format `{$post_type}_{$thumb_id}_thumbnail_html` which allows filtering by post type and thumbnail id which was the intent.