reGenerate Thumbnails Advanced - Version 0.8.2.4

Version Description

*Added time (in seconds) to each processed image - You can see how long each image took *Error log status changes at the end from Processing to "No errors" if there are no errors.

=

Download this release

Release Info

Developer turcuciprian
Plugin Icon 128x128 reGenerate Thumbnails Advanced
Version 0.8.2.4
Comparing to
See all releases

Code changes from version 0.8.2.3 to 0.8.2.4

Files changed (4) hide show
  1. README.md +0 -0
  2. readme.txt +9 -2
  3. regenerate-thumbnails-advanced.php +23 -24
  4. script.js +48 -36
README.md CHANGED
File without changes
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: turcuciprian
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MU4RJNNF74QKY
4
  Tags: regenerate, thumbnails, advanced, easy, day, weeek, month
5
  Requires at least: 4.0
6
- Tested up to: 4.2.4
7
- Stable tag: 0.8.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -78,6 +78,10 @@ The script stops, it does not run in the background
78
  *Progress and errors aligned with containers
79
  *javascript changed so that it shows processing for errors when processing starts
80
 
 
 
 
 
81
  == Upgrade Notice ==
82
 
83
  = 0.7 =
@@ -99,4 +103,7 @@ No issuse with this version that require attention. Small update change
99
  No issuse with this version that require attention. Small update change. It's basically a feature, so unless you want it, the older version works great.
100
 
101
  = 0.8.2.3 =
 
 
 
102
  No issuse with this version that require attention. Small update change. It's basically a feature, so unless you want it, the older version works great.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MU4RJNNF74QKY
4
  Tags: regenerate, thumbnails, advanced, easy, day, weeek, month
5
  Requires at least: 4.0
6
+ Tested up to: 4.3
7
+ Stable tag: 0.8.2.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
78
  *Progress and errors aligned with containers
79
  *javascript changed so that it shows processing for errors when processing starts
80
 
81
+ = 0.8.2.4 =
82
+ *Added time (in seconds) to each processed image - You can see how long each image took
83
+ *Error log status changes at the end from Processing to "No errors" if there are no errors.
84
+
85
  == Upgrade Notice ==
86
 
87
  = 0.7 =
103
  No issuse with this version that require attention. Small update change. It's basically a feature, so unless you want it, the older version works great.
104
 
105
  = 0.8.2.3 =
106
+ No issuse with this version that require attention. Small update change. It's basically a feature, so unless you want it, the older version works great.
107
+
108
+ = 0.8.2.4 =
109
  No issuse with this version that require attention. Small update change. It's basically a feature, so unless you want it, the older version works great.
regenerate-thumbnails-advanced.php CHANGED
@@ -1,9 +1,10 @@
1
  <?php
 
2
  /*
3
  Plugin Name: reGenerate Thumbnails - advanced
4
  Plugin URI: http://turcuciprian.com
5
  Description: A plugin that makes regenerating thumbnails even easier than before and more flexible.
6
- Version: 0.8.2.3
7
  Author: turcuciprian
8
  Author URI: http://turcuciprian.com
9
  License: GPLv2 or later
@@ -12,7 +13,7 @@
12
 
13
  //Global variables for arguments
14
 
15
- class cc {
16
 
17
  // create basic page in the admin panel, with menu settings too
18
  public function start() {
@@ -33,7 +34,7 @@ class cc {
33
  $args = array(
34
  'post_type' => 'attachment',
35
  'posts_per_page' => -1,
36
- 'post_status' => 'any',
37
  'offset' => 0
38
  );
39
 
@@ -76,7 +77,7 @@ class cc {
76
  echo json_encode($return_arr);
77
  break;
78
  case 'submit':
79
- $logstatus='';
80
  $error = array();
81
  if (isset($_POST['offset'])) {
82
  $offset = $_POST['offset'];
@@ -136,48 +137,45 @@ class cc {
136
  $is_image = true;
137
  $fullsizepath = get_attached_file($image_id);
138
  //is image:
139
- if(!is_array(getimagesize($fullsizepath))){
140
  $is_image = false;
141
-
142
  }
143
- if($is_image){
144
  if (false === $fullsizepath || !file_exists($fullsizepath))
145
- $error[] = '<code>' . esc_html($fullsizepath) . '</code>';
146
-
147
  @set_time_limit(900);
148
  $metadata = wp_generate_attachment_metadata($image_id, $fullsizepath);
149
  //get the attachment name
150
- $filename_only = basename( get_attached_file( $image_id ) );
151
  if (is_wp_error($metadata)) {
152
- $error[] = sprint_f("%s Image ID:%d",$metadata->get_error_message(),$image_id);
153
  }
154
  if (empty($metadata)) {
155
  //$this->die_json_error_msg($image_id, __('Unknown failure reason.', 'regenerate-thumbnails'));
156
- $error[] = sprint_f('Unknown failure reason. regenerate-thumbnails %d', $image_id);
157
-
158
- }else{
159
  wp_update_attachment_metadata($image_id, $metadata);
160
  }
161
- $logstatus = "<br/>".$filename_only." - <b>Processed</b>";
162
- }else{
163
- $filename_only = basename( get_attached_file( $image_id ) );
164
-
165
- $error[]=sprintf('Attachment (<b>%s</b> - ID:%d) is not an image. Skipping',$filename_only,$image_id);
166
  }
167
  }
168
-
169
  } else {
170
  $error[] = "No pictures uploaded";
171
  }
172
-
173
-
174
  //
175
  if (!extension_loaded('gd') && !function_exists('gd_info')) {
176
- $error[]= "<b>PHP GD library is not installed</b> on your web server. Please install in order to have the ability to resize and crop images";
177
  }
178
  //increment offset
179
  $result = $offset + 1;
180
- echo json_encode(array('offset'=>($offset+1),'error'=>$error,'logstatus'=>$logstatus));
181
  break;
182
  }
183
  /* Restore original Post Data */
@@ -185,6 +183,7 @@ class cc {
185
 
186
  wp_die();
187
  }
 
188
  // Admin menu calback
189
  public function create_menu() {
190
  global $cc_args;
1
  <?php
2
+
3
  /*
4
  Plugin Name: reGenerate Thumbnails - advanced
5
  Plugin URI: http://turcuciprian.com
6
  Description: A plugin that makes regenerating thumbnails even easier than before and more flexible.
7
+ Version: 0.8.2.4
8
  Author: turcuciprian
9
  Author URI: http://turcuciprian.com
10
  License: GPLv2 or later
13
 
14
  //Global variables for arguments
15
 
16
+ class cc {
17
 
18
  // create basic page in the admin panel, with menu settings too
19
  public function start() {
34
  $args = array(
35
  'post_type' => 'attachment',
36
  'posts_per_page' => -1,
37
+ 'post_status' => 'any',
38
  'offset' => 0
39
  );
40
 
77
  echo json_encode($return_arr);
78
  break;
79
  case 'submit':
80
+ $logstatus = '';
81
  $error = array();
82
  if (isset($_POST['offset'])) {
83
  $offset = $_POST['offset'];
137
  $is_image = true;
138
  $fullsizepath = get_attached_file($image_id);
139
  //is image:
140
+ if (!is_array(getimagesize($fullsizepath))) {
141
  $is_image = false;
 
142
  }
143
+ if ($is_image) {
144
  if (false === $fullsizepath || !file_exists($fullsizepath))
145
+ $error[] = '<code>' . esc_html($fullsizepath) . '</code>';
146
+
147
  @set_time_limit(900);
148
  $metadata = wp_generate_attachment_metadata($image_id, $fullsizepath);
149
  //get the attachment name
150
+ $filename_only = basename(get_attached_file($image_id));
151
  if (is_wp_error($metadata)) {
152
+ $error[] = sprint_f("%s Image ID:%d", $metadata->get_error_message(), $image_id);
153
  }
154
  if (empty($metadata)) {
155
  //$this->die_json_error_msg($image_id, __('Unknown failure reason.', 'regenerate-thumbnails'));
156
+ $error[] = sprint_f('Unknown failure reason. regenerate-thumbnails %d', $image_id);
157
+ } else {
 
158
  wp_update_attachment_metadata($image_id, $metadata);
159
  }
160
+ $logstatus = "<br/>" . $filename_only . " - <b>Processed</b>";
161
+ } else {
162
+ $filename_only = basename(get_attached_file($image_id));
163
+
164
+ $error[] = sprintf('Attachment (<b>%s</b> - ID:%d) is not an image. Skipping', $filename_only, $image_id);
165
  }
166
  }
 
167
  } else {
168
  $error[] = "No pictures uploaded";
169
  }
170
+
171
+
172
  //
173
  if (!extension_loaded('gd') && !function_exists('gd_info')) {
174
+ $error[] = "<b>PHP GD library is not installed</b> on your web server. Please install in order to have the ability to resize and crop images";
175
  }
176
  //increment offset
177
  $result = $offset + 1;
178
+ echo json_encode(array('offset' => ($offset + 1), 'error' => $error, 'logstatus' => $logstatus, 'startTime' => $_POST['startTime']));
179
  break;
180
  }
181
  /* Restore original Post Data */
183
 
184
  wp_die();
185
  }
186
+
187
  // Admin menu calback
188
  public function create_menu() {
189
  global $cc_args;
script.js CHANGED
@@ -2,7 +2,7 @@ jQuery(document).ready(function ($) {
2
  //no js error
3
  $('#no-js').addClass('hidden');
4
  $('#js-works').removeClass('hidden');
5
-
6
  //the main script
7
  var err_arr = [];
8
  var errors_obj = $('#rta .errors');
@@ -19,7 +19,7 @@ jQuery(document).ready(function ($) {
19
  if (rta_butt[0]) {
20
  var logstatus = $('#rta .logstatus');
21
  var errstatus = $('#rta .errors');
22
-
23
  rta_butt.click(submit_ajax_call);
24
  //
25
  //LOOP REQUEST ... ajax request to call when the button is pressed
@@ -27,40 +27,44 @@ jQuery(document).ready(function ($) {
27
  function submit_ajax_call() {
28
  logstatus.html('Processing...');
29
  errstatus.html('Processing...');
30
- err_arr=[];
31
  var period = $('#rta_period');
 
 
32
  // First Time Request
33
- loop_ajax_request('general', 0, -1, period.val());
34
-
35
-
36
  }
37
  //
38
  //
39
  // Main ajax call
40
  //
41
  //
42
- function loop_ajax_request(type, offset, tCount, period) {
43
 
44
  //tha ajax data
45
  var data = {
46
  'action': 'rta_ajax',
47
  'type': type,
 
48
  'period': period,
49
  'offset': offset
50
  };
51
  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
52
  $.post(ajaxurl, data, function (response) {
 
53
  //var err_arr = new Array();
54
  //json response
55
  var json = JSON.parse(response);
 
56
  var offset = 0;
57
  var tCount = 0;
58
  var rta_total = $('#rta .info .total');
59
-
60
  // console.log(response);
61
  switch (type) {
62
  case 'general':
63
- //console.log(response);
64
  var period = $('#rta_period');
65
  var rta_total = $('#rta .info .total');
66
  var rta_processed = $('#rta .info .processed');
@@ -69,22 +73,22 @@ jQuery(document).ready(function ($) {
69
  rta_total.html(json.pCount);
70
  rta_processed.html("0");
71
  }
72
-
73
  if (rta_total[0]) {
74
  tCount = rta_total.html();
75
  }
76
- loop_ajax_request('submit', offset, tCount, period.val(), false);
 
77
 
78
  break;
79
  case 'submit':
80
- // console.log(response);
81
  if (rta_total[0]) {
82
  tCount = rta_total.html();
83
  }
84
  var processed = $('#rta .info .processed');
85
-
86
  var progressbar_percentage = $('#progressbar .progress-label');
87
- if (processed[0] && rta_total.html()!=0) {
88
  processed.html(json.offset);
89
  }
90
  tCount = parseInt(tCount);
@@ -103,56 +107,64 @@ jQuery(document).ready(function ($) {
103
  lPercentage = Math.floor(lPercentage) + '%';
104
  progressbar_percentage.html(lPercentage);
105
  }
 
 
106
  //Add to log
107
- logstatus.html(logstatus.html()+json.logstatus);
108
  //call function again
109
  if (tCount > response) {
110
  //append unique errors
111
  unique_arr_append(json.error);
112
  //make a new request to the ajax call
113
- loop_ajax_request(type, offset, tCount, period);
114
- }else{
 
 
 
 
 
 
115
  //the loop ended show errors and messages
116
- $.each(err_arr,function( index, value ){
117
- var final_val = '<div class="ui-state-error">'+value+'</div>';
118
- errors_obj.html(errors_obj.html()+final_val);
119
  });
120
-
121
  }
122
- }else{
123
  unique_arr_append(json.error);
124
  //the loop ended show errors and messages
125
- $.each(err_arr,function( index, value ){
126
- var final_val = '<div class="ui-state-error">'+value+'</div>';
127
- errors_obj.html(errors_obj.html()+final_val);
128
- });
129
  }
130
  break;
131
  }
132
  });
133
  }
134
  // Append only unique array values
135
- function unique_arr_append(val){
136
  var unique = true;
137
  var i = 0;
138
  var y = 0;
139
- while(val[i]){
140
  unique = true;
141
- y=0;
142
- while(err_arr[y]){
143
- if(err_arr[y]==val[i]){
144
- console.log(err_arr[i]);
145
  unique = false;
146
  break;
147
  }
148
  y++;
149
  }
150
- if(unique){
151
- err_arr.push(val[i]);
152
- }
153
  i++;
154
  }
155
-
156
  }
157
  }
158
  });
2
  //no js error
3
  $('#no-js').addClass('hidden');
4
  $('#js-works').removeClass('hidden');
5
+
6
  //the main script
7
  var err_arr = [];
8
  var errors_obj = $('#rta .errors');
19
  if (rta_butt[0]) {
20
  var logstatus = $('#rta .logstatus');
21
  var errstatus = $('#rta .errors');
22
+
23
  rta_butt.click(submit_ajax_call);
24
  //
25
  //LOOP REQUEST ... ajax request to call when the button is pressed
27
  function submit_ajax_call() {
28
  logstatus.html('Processing...');
29
  errstatus.html('Processing...');
30
+ err_arr = [];
31
  var period = $('#rta_period');
32
+ var startTime = new Date().getTime();
33
+
34
  // First Time Request
35
+ loop_ajax_request('general', 0, -1, period.val(), startTime);
36
+
37
+
38
  }
39
  //
40
  //
41
  // Main ajax call
42
  //
43
  //
44
+ function loop_ajax_request(type, offset, tCount, period, startTime) {
45
 
46
  //tha ajax data
47
  var data = {
48
  'action': 'rta_ajax',
49
  'type': type,
50
+ 'startTime': startTime,
51
  'period': period,
52
  'offset': offset
53
  };
54
  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
55
  $.post(ajaxurl, data, function (response) {
56
+
57
  //var err_arr = new Array();
58
  //json response
59
  var json = JSON.parse(response);
60
+ var startTime = json.startTime;
61
  var offset = 0;
62
  var tCount = 0;
63
  var rta_total = $('#rta .info .total');
64
+
65
  // console.log(response);
66
  switch (type) {
67
  case 'general':
 
68
  var period = $('#rta_period');
69
  var rta_total = $('#rta .info .total');
70
  var rta_processed = $('#rta .info .processed');
73
  rta_total.html(json.pCount);
74
  rta_processed.html("0");
75
  }
76
+
77
  if (rta_total[0]) {
78
  tCount = rta_total.html();
79
  }
80
+ var startTime = new Date().getTime();
81
+ loop_ajax_request('submit', offset, tCount, period.val(), startTime);
82
 
83
  break;
84
  case 'submit':
 
85
  if (rta_total[0]) {
86
  tCount = rta_total.html();
87
  }
88
  var processed = $('#rta .info .processed');
89
+
90
  var progressbar_percentage = $('#progressbar .progress-label');
91
+ if (processed[0] && rta_total.html() != 0) {
92
  processed.html(json.offset);
93
  }
94
  tCount = parseInt(tCount);
107
  lPercentage = Math.floor(lPercentage) + '%';
108
  progressbar_percentage.html(lPercentage);
109
  }
110
+ var processTime = new Date().getTime() - startTime;
111
+ processTime = processTime / 1000;
112
  //Add to log
113
+ logstatus.html(logstatus.html() + json.logstatus + '- in ' + processTime + ' seconds');
114
  //call function again
115
  if (tCount > response) {
116
  //append unique errors
117
  unique_arr_append(json.error);
118
  //make a new request to the ajax call
119
+ var startTime = new Date().getTime();
120
+ loop_ajax_request(type, offset, tCount, period, startTime);
121
+ } else {
122
+ console.log('Processing Completed!');
123
+ var errStatus = $('#rta .errors');
124
+ if(errStatus.html()=="Processing..."){
125
+ errStatus.html('No Errors.');
126
+ }
127
  //the loop ended show errors and messages
128
+ $.each(err_arr, function (index, value) {
129
+ var final_val = '<div class="ui-state-error">' + value + '</div>';
130
+ errors_obj.html(errors_obj.html() + final_val);
131
  });
132
+
133
  }
134
+ } else {
135
  unique_arr_append(json.error);
136
  //the loop ended show errors and messages
137
+ $.each(err_arr, function (index, value) {
138
+ var final_val = '<div class="ui-state-error">' + value + '</div>';
139
+ errors_obj.html(errors_obj.html() + final_val);
140
+ });
141
  }
142
  break;
143
  }
144
  });
145
  }
146
  // Append only unique array values
147
+ function unique_arr_append(val) {
148
  var unique = true;
149
  var i = 0;
150
  var y = 0;
151
+ while (val[i]) {
152
  unique = true;
153
+ y = 0;
154
+ while (err_arr[y]) {
155
+ if (err_arr[y] == val[i]) {
156
+ // console.log(err_arr[i]);
157
  unique = false;
158
  break;
159
  }
160
  y++;
161
  }
162
+ if (unique) {
163
+ err_arr.push(val[i]);
164
+ }
165
  i++;
166
  }
167
+
168
  }
169
  }
170
  });