AJAX Thumbnail Rebuild - Version 1.05

Version Description

  • Add option to only rebuild post thumbnails (featured images)
Download this release

Release Info

Developer junkcoder
Plugin Icon wp plugin AJAX Thumbnail Rebuild
Version 1.05
Comparing to
See all releases

Code changes from version 1.04 to 1.05

Files changed (2) hide show
  1. ajax-thumbnail-rebuild.php +41 -10
  2. readme.txt +6 -2
ajax-thumbnail-rebuild.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin URI: http://breiti.cc/wordpress/ajax-thumbnail-rebuild
4
  Author: junkcoder
5
  Author URI: http://breiti.cc
6
- Version: 1.03
7
  Description: Rebuild all thumbnails
8
  Max WP Version: 3.0.1
9
 
@@ -56,10 +56,12 @@ class AjaxThumbnailRebuild {
56
  } );
57
  }
58
 
 
 
59
  jQuery.ajax({
60
  url: "<?php bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php",
61
  type: "POST",
62
- data: "action=ajax_thumbnail_rebuild&do=getlist",
63
  success: function(result) {
64
  var list = eval(result);
65
  var curr = 0;
@@ -129,6 +131,11 @@ class AjaxThumbnailRebuild {
129
  <br/>
130
  <?php endforeach;?>
131
  </p>
 
 
 
 
 
132
  <input type="button" onClick="javascript:regenerate();" class="button"
133
  name="ajax_thumbnail_rebuild" id="ajax_thumbnail_rebuild"
134
  value="<?php _e( 'Regenerate All Thumbnails', 'ajax-thumbnail-rebuild' ) ?>" />
@@ -149,18 +156,42 @@ class AjaxThumbnailRebuild {
149
  };
150
 
151
  function ajax_thumbnail_rebuild_ajax() {
 
 
152
  $action = $_POST["do"];
153
  $thumbnails = isset( $_POST['thumbnails'] )? $_POST['thumbnails'] : NULL;
 
154
 
155
  if ($action == "getlist") {
156
- $attachments =& get_children( array(
157
- 'post_type' => 'attachment',
158
- 'post_mime_type' => 'image',
159
- 'numberposts' => -1,
160
- 'post_status' => null,
161
- 'post_parent' => null, // any parent
162
- 'output' => 'object',
163
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  foreach ( $attachments as $attachment ) {
166
  $res[] = array('id' => $attachment->ID, 'title' => $attachment->post_title);
3
  Plugin URI: http://breiti.cc/wordpress/ajax-thumbnail-rebuild
4
  Author: junkcoder
5
  Author URI: http://breiti.cc
6
+ Version: 1.05
7
  Description: Rebuild all thumbnails
8
  Max WP Version: 3.0.1
9
 
56
  } );
57
  }
58
 
59
+ var onlypostthumbs = jQuery("#onlypostthumbs").attr('checked') ? 1 : 0;
60
+
61
  jQuery.ajax({
62
  url: "<?php bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php",
63
  type: "POST",
64
+ data: "action=ajax_thumbnail_rebuild&do=getlist&onlypostthumbs="+onlypostthumbs,
65
  success: function(result) {
66
  var list = eval(result);
67
  var curr = 0;
131
  <br/>
132
  <?php endforeach;?>
133
  </p>
134
+ <p>
135
+ <input type="checkbox" id="onlypostthumbs" name="onlypostthumbs" />
136
+ <label>Only rebuild post thumbnails</label>
137
+ </p>
138
+
139
  <input type="button" onClick="javascript:regenerate();" class="button"
140
  name="ajax_thumbnail_rebuild" id="ajax_thumbnail_rebuild"
141
  value="<?php _e( 'Regenerate All Thumbnails', 'ajax-thumbnail-rebuild' ) ?>" />
156
  };
157
 
158
  function ajax_thumbnail_rebuild_ajax() {
159
+ global $wpdb;
160
+
161
  $action = $_POST["do"];
162
  $thumbnails = isset( $_POST['thumbnails'] )? $_POST['thumbnails'] : NULL;
163
+ $onlypostthumbs = isset( $_POST['onlypostthumbs'] ) ? $_POST['onlypostthumbs'] : 0;
164
 
165
  if ($action == "getlist") {
166
+
167
+ if ($onlypostthumbs) {
168
+ /* Get all featured images */
169
+ $featured_images = $wpdb->get_results( "SELECT meta_value FROM {$wpdb->postmeta}
170
+ WHERE meta_key = '_thumbnail_id'" );
171
+
172
+ $thumbs = array();
173
+ foreach($featured_images as $image) {
174
+ array_push($thumbs, $image->meta_value);
175
+ }
176
+ $attachments =& get_children( array(
177
+ 'post_type' => 'attachment',
178
+ 'post_mime_type' => 'image',
179
+ 'numberposts' => -1,
180
+ 'post_status' => null,
181
+ 'post_in' => $thumbs,
182
+ 'output' => 'object',
183
+ ) );
184
+
185
+ } else {
186
+ $attachments =& get_children( array(
187
+ 'post_type' => 'attachment',
188
+ 'post_mime_type' => 'image',
189
+ 'numberposts' => -1,
190
+ 'post_status' => null,
191
+ 'post_parent' => null, // any parent
192
+ 'output' => 'object',
193
+ ) );
194
+ }
195
 
196
  foreach ( $attachments as $attachment ) {
197
  $res[] = array('id' => $attachment->ID, 'title' => $attachment->post_title);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: junkcoder
3
  Tags: ajax, thumbnail, rebuild, regenerate, admin
4
  Requires at least: 2.8
5
  Tested up to: 3.2
6
- Stable tag: 1.04
7
 
8
  AJAX Thumbnail Rebuild allows you to rebuild all thumbnails at once without script timeouts on your server.
9
 
@@ -13,7 +13,7 @@ AJAX Thumbnail Rebuild allows you to rebuild all thumbnails on your site. There
13
 
14
  Why would you want to rebuild your thumbnails? Wordpress allows you to change the size of thumbnails. This way, you can make the size of thumbnails fit the design of your website. When you change the size to fit for a new theme, all future photos you are going to upload will have this new size. Your old thumbnails won’t be resized. That’s where this plugin comes into action. After changing the image sizes, you can rebuild all thumbnails. But instead of telling the server to recreate all thumbnails at once, they are rebuilt one after another. Rebuilding thumbnails for one photo won’t take all too long, so you won’t run into any script timeouts. Note that you still have to wait until all thumbnails have been rebuilt. If you close the page before the task is completed, you have to start all over again.
15
 
16
- You can also select the thumbnail sizes you want to rebuild, so that you don't need to recreate all images if you've just changed one thumbnail-size.
17
 
18
  This plugin requires JavaScript to be enabled.
19
 
@@ -23,6 +23,10 @@ Upload the plugin to your blog, activate it, done. You can then rebuild all thum
23
 
24
  == Changelog ==
25
 
 
 
 
 
26
  = 1.04 =
27
 
28
  * Tested with Wordpress 3.2
3
  Tags: ajax, thumbnail, rebuild, regenerate, admin
4
  Requires at least: 2.8
5
  Tested up to: 3.2
6
+ Stable tag: 1.05
7
 
8
  AJAX Thumbnail Rebuild allows you to rebuild all thumbnails at once without script timeouts on your server.
9
 
13
 
14
  Why would you want to rebuild your thumbnails? Wordpress allows you to change the size of thumbnails. This way, you can make the size of thumbnails fit the design of your website. When you change the size to fit for a new theme, all future photos you are going to upload will have this new size. Your old thumbnails won’t be resized. That’s where this plugin comes into action. After changing the image sizes, you can rebuild all thumbnails. But instead of telling the server to recreate all thumbnails at once, they are rebuilt one after another. Rebuilding thumbnails for one photo won’t take all too long, so you won’t run into any script timeouts. Note that you still have to wait until all thumbnails have been rebuilt. If you close the page before the task is completed, you have to start all over again.
15
 
16
+ You can also select the thumbnail sizes you want to rebuild, so that you don't need to recreate all images if you've just changed one thumbnail-size. You can also choose to only rebuild post thumbnails (featured images).
17
 
18
  This plugin requires JavaScript to be enabled.
19
 
23
 
24
  == Changelog ==
25
 
26
+ = 1.05 =
27
+
28
+ * Add option to only rebuild post thumbnails (featured images)
29
+
30
  = 1.04 =
31
 
32
  * Tested with Wordpress 3.2