Regenerate Thumbnails - Version 2.2.0

Version Description

Download this release

Release Info

Developer Viper007Bond
Plugin Icon 128x128 Regenerate Thumbnails
Version 2.2.0
Comparing to
See all releases

Code changes from version 2.1.2 to 2.2.0

Files changed (2) hide show
  1. readme.txt +11 -3
  2. regenerate-thumbnails.php +20 -6
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Viper007Bond
3
  Donate link: http://www.viper007bond.com/donate/
4
  Tags: thumbnail, thumbnails
5
  Requires at least: 2.8
6
- Tested up to: 3.0
7
  Stable tag: trunk
8
 
9
  Allows you to regenerate your thumbnails after changing the thumbnail sizes.
@@ -12,7 +12,7 @@ Allows you to regenerate your thumbnails after changing the thumbnail sizes.
12
 
13
  Regenerate Thumbnails allows you to regenerate the thumbnails for your image attachments. This is very handy if you've changed any of your thumbnail dimensions (via Settings -> Media) after previously uploading images or have changed to a theme with different featured post image dimensions.
14
 
15
- You can either regenerate the thumbnails for all image uploads, individual image uploads, or specific multiple image uploads (WordPress 3.1+ only).
16
 
17
  See the [screenshots tab](http://wordpress.org/extend/plugins/regenerate-thumbnails/screenshots/) for more details.
18
 
@@ -27,10 +27,18 @@ See the [screenshots tab](http://wordpress.org/extend/plugins/regenerate-thumbna
27
 
28
  1. The plugin at work regenerating thumbnails
29
  2. You can resize single images by hovering over their row in the Media Library
30
- 2. You can resize specific multiples images using the checkboxes and the "Bulk Actions" dropdown (WordPress 3.1+ only)
31
 
32
  == ChangeLog ==
33
 
 
 
 
 
 
 
 
 
34
  = Version 2.1.2 =
35
 
36
  * When regenerating all images, newest images are done first rather than the oldest.
3
  Donate link: http://www.viper007bond.com/donate/
4
  Tags: thumbnail, thumbnails
5
  Requires at least: 2.8
6
+ Tested up to: 3.1
7
  Stable tag: trunk
8
 
9
  Allows you to regenerate your thumbnails after changing the thumbnail sizes.
12
 
13
  Regenerate Thumbnails allows you to regenerate the thumbnails for your image attachments. This is very handy if you've changed any of your thumbnail dimensions (via Settings -> Media) after previously uploading images or have changed to a theme with different featured post image dimensions.
14
 
15
+ You can either regenerate the thumbnails for all image uploads, individual image uploads, or specific multiple image uploads.
16
 
17
  See the [screenshots tab](http://wordpress.org/extend/plugins/regenerate-thumbnails/screenshots/) for more details.
18
 
27
 
28
  1. The plugin at work regenerating thumbnails
29
  2. You can resize single images by hovering over their row in the Media Library
30
+ 2. You can resize specific multiples images using the checkboxes and the "Bulk Actions" dropdown
31
 
32
  == ChangeLog ==
33
 
34
+ = Version 2.2.0 =
35
+
36
+ * Changes to the Bulk Action functionality were made shortly before the release of WordPress 3.1 which broke the way I implemented the specific multiple image regeneration feature. This version adds to the Bulk Action menu using Javascript as that's the only way to do it currently.
37
+
38
+ = Version 2.1.3 =
39
+
40
+ * Move the `error_reporting()` call in the AJAX handler to the beginning so that we're more sure that no PHP errors are outputted. Some hosts disable usage of `set_time_limit()` and calling it was causing a PHP warning to be outputted.
41
+
42
  = Version 2.1.2 =
43
 
44
  * When regenerating all images, newest images are done first rather than the oldest.
regenerate-thumbnails.php CHANGED
@@ -5,7 +5,7 @@
5
  Plugin Name: Regenerate Thumbnails
6
  Plugin URI: http://www.viper007bond.com/wordpress-plugins/regenerate-thumbnails/
7
  Description: Allows you to regenerate all thumbnails after changing the thumbnail sizes.
8
- Version: 2.1.2
9
  Author: Viper007Bond
10
  Author URI: http://www.viper007bond.com/
11
 
@@ -44,7 +44,8 @@ class RegenerateThumbnails {
44
  add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueues' ) );
45
  add_action( 'wp_ajax_regeneratethumbnail', array( &$this, 'ajax_process_image' ) );
46
  add_filter( 'media_row_actions', array( &$this, 'add_media_row_action' ), 10, 2 );
47
- add_filter( 'bulk_actions-upload', array( &$this, 'add_bulk_actions' ), 99 );
 
48
  add_action( 'admin_action_bulk_regenerate_thumbnails', array( &$this, 'bulk_action_handler' ) );
49
  }
50
 
@@ -99,14 +100,26 @@ class RegenerateThumbnails {
99
  }
100
 
101
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  // Handles the bulk actions POST
103
  function bulk_action_handler() {
104
  check_admin_referer( 'bulk-media' );
105
 
106
- if ( empty( $_POST['media'] ) && is_array( $_POST['media'] ) )
107
  return;
108
 
109
- $ids = implode( ',', array_map( 'intval', $_POST['media'] ) );
110
 
111
  // Can't use wp_nonce_url() as it escapes HTML entities
112
  wp_redirect( add_query_arg( '_wpnonce', wp_create_nonce( 'regenerate-thumbnails' ), admin_url( 'tools.php?page=regenerate-thumbnails&goback=1&ids=' . $ids ) ) );
@@ -323,6 +336,8 @@ class RegenerateThumbnails {
323
 
324
  // Process a single image ID (this is an AJAX handler)
325
  function ajax_process_image() {
 
 
326
  header( 'Content-type: application/json' );
327
 
328
  $id = (int) $_REQUEST['id'];
@@ -339,8 +354,7 @@ class RegenerateThumbnails {
339
  if ( false === $fullsizepath || ! file_exists( $fullsizepath ) )
340
  $this->die_json_error_msg( $image->ID, sprintf( __( 'The originally uploaded image file cannot be found at %s', 'regenerate-thumbnails' ), '<code>' . esc_html( $fullsizepath ) . '</code>' ) );
341
 
342
- set_time_limit( 900 ); // 5 minutes per image should be PLENTY, lol
343
- error_reporting( 0 ); // Don't break the JSON result
344
 
345
  $metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );
346
 
5
  Plugin Name: Regenerate Thumbnails
6
  Plugin URI: http://www.viper007bond.com/wordpress-plugins/regenerate-thumbnails/
7
  Description: Allows you to regenerate all thumbnails after changing the thumbnail sizes.
8
+ Version: 2.2.0
9
  Author: Viper007Bond
10
  Author URI: http://www.viper007bond.com/
11
 
44
  add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueues' ) );
45
  add_action( 'wp_ajax_regeneratethumbnail', array( &$this, 'ajax_process_image' ) );
46
  add_filter( 'media_row_actions', array( &$this, 'add_media_row_action' ), 10, 2 );
47
+ //add_filter( 'bulk_actions-upload', array( &$this, 'add_bulk_actions' ), 99 ); // A last minute change to 3.1 makes this no longer work
48
+ add_action( 'admin_head-upload.php', array( &$this, 'add_bulk_actions_via_javascript' ) );
49
  add_action( 'admin_action_bulk_regenerate_thumbnails', array( &$this, 'bulk_action_handler' ) );
50
  }
51
 
100
  }
101
 
102
 
103
+ // Add new items to the Bulk Actions using Javascript
104
+ // A last minute change to the "bulk_actions-xxxxx" filter in 3.1 made it not possible to add items using that
105
+ function add_bulk_actions_via_javascript() { ?>
106
+ <script type="text/javascript">
107
+ jQuery(document).ready(function($){
108
+ $('select[name^="action"] option:last-child').before('<option value="bulk_regenerate_thumbnails"><?php echo esc_attr( __( 'Regenerate Thumbnails', 'regenerate-thumbnails' ) ); ?></option>');
109
+ });
110
+ </script>
111
+ <?php
112
+ }
113
+
114
+
115
  // Handles the bulk actions POST
116
  function bulk_action_handler() {
117
  check_admin_referer( 'bulk-media' );
118
 
119
+ if ( empty( $_REQUEST['media'] ) || ! is_array( $_REQUEST['media'] ) )
120
  return;
121
 
122
+ $ids = implode( ',', array_map( 'intval', $_REQUEST['media'] ) );
123
 
124
  // Can't use wp_nonce_url() as it escapes HTML entities
125
  wp_redirect( add_query_arg( '_wpnonce', wp_create_nonce( 'regenerate-thumbnails' ), admin_url( 'tools.php?page=regenerate-thumbnails&goback=1&ids=' . $ids ) ) );
336
 
337
  // Process a single image ID (this is an AJAX handler)
338
  function ajax_process_image() {
339
+ @error_reporting( 0 ); // Don't break the JSON result
340
+
341
  header( 'Content-type: application/json' );
342
 
343
  $id = (int) $_REQUEST['id'];
354
  if ( false === $fullsizepath || ! file_exists( $fullsizepath ) )
355
  $this->die_json_error_msg( $image->ID, sprintf( __( 'The originally uploaded image file cannot be found at %s', 'regenerate-thumbnails' ), '<code>' . esc_html( $fullsizepath ) . '</code>' ) );
356
 
357
+ @set_time_limit( 900 ); // 5 minutes per image should be PLENTY
 
358
 
359
  $metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );
360