reGenerate Thumbnails Advanced - Version 1.0.1

Version Description

Removed unnecesary functionality. Just the checkbox for OTF is now available.

=

Download this release

Release Info

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

Code changes from version 1.0 to 1.0.1

Files changed (3) hide show
  1. readme.txt +11 -5
  2. regenerate-thumbnails-advanced.php +20 -46
  3. script.js +5 -187
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  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.3.1
7
- Stable tag: 1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -13,8 +13,8 @@ Description: A plugin that makes regenerating thumbnails even easier than before
13
  == Description ==
14
 
15
  A plugin that makes regenerating thumbnails even easier than before and more flexible.
16
- If you install a new theme, it might have different image sizes it wants to use. those image sizes are cropped and resized into thumbnails only when you upload new images. So what happens with your old images?
17
- the ones you already uploaded? They need to be regenerated, this is what this plugin does. It takes each image and generates the thumbnails for each and every one of them.
18
 
19
 
20
  Features:
@@ -96,6 +96,9 @@ The script stops, it does not run in the background
96
  = 1.0 =
97
  *Regenerate on the fly
98
 
 
 
 
99
  == Upgrade Notice ==
100
 
101
  = 0.7 =
@@ -129,4 +132,7 @@ No issuse with this version that require attention. Small update change. It's ba
129
  This version changes the style and adds a bit of functionality to the general settings (a date start-end option to choose from)
130
 
131
  = 1.0 =
132
- This version
 
 
 
2
  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.3.1
7
+ Stable tag: 1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
13
  == Description ==
14
 
15
  A plugin that makes regenerating thumbnails even easier than before and more flexible.
16
+ If you install a new theme, it might have different image sizes it wants to use. those image sizes are cropped and resized into thumbnails only when you upload new images. So what happens with your old images?
17
+ the ones you already uploaded? They need to be regenerated, this is what this plugin does. It takes each image and generates the thumbnails for each and every one of them.
18
 
19
 
20
  Features:
96
  = 1.0 =
97
  *Regenerate on the fly
98
 
99
+ = 1.0.1 =
100
+ Removed unnecesary functionality. Just the checkbox for OTF is now available.
101
+
102
  == Upgrade Notice ==
103
 
104
  = 0.7 =
132
  This version changes the style and adds a bit of functionality to the general settings (a date start-end option to choose from)
133
 
134
  = 1.0 =
135
+ This version changes the style and adds a bit of functionality to the general settings (a date start-end option to choose from)
136
+
137
+ = 1.0.1 =
138
+ nothing that affect the previous data is changed. Update is save
regenerate-thumbnails-advanced.php CHANGED
@@ -3,7 +3,7 @@
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: 1.0
7
  Author: turcuciprian
8
  Author URI: http://turcuciprian.com
9
  License: GPLv2 or later
@@ -11,6 +11,7 @@
11
  */
12
 
13
  //Global variables for arguments
 
14
  class cc {
15
 
16
  // create basic page in the admin panel, with menu settings too
@@ -26,8 +27,13 @@ class cc {
26
 
27
  public function ajaxOtfCallback() {
28
  if (isset($_POST['otfVal'])) {
 
 
29
  $tempValue = $_POST['tempValue'];
30
- update_option('rtaOTF', $tempValue);
 
 
 
31
  }
32
  }
33
 
@@ -226,7 +232,7 @@ class cc {
226
  }
227
 
228
  function enqueue_admin($hook) {
229
- if (!isset($_GET['page']) && isset($hook)) {
230
  if ($_GET['page'] !== 'regenerate_thumbnails_advanced' && $hook != 'options-general.php ') {
231
  return;
232
  }
@@ -250,46 +256,7 @@ class cc {
250
  <p>If there is a error in the page (most likely caused by another plugin or even the theme, the regenerate thumbnails advanced plugin will not work properly. Please fix this issue and come back here. YOU WILL NOT SEE THIS WARNING IF EVERYTHING IS WORKING FINE</p>
251
  </div>
252
  <div id="js-works" class="hidden">
253
- <h2>reGenerate Thumbnails Advanced</h2>
254
- <!--Progress bar-->
255
- <div id="progressbar">
256
- <div class="progress-label">0&#37;</div>
257
- </div>
258
- <!--Information section-->
259
- <div class="info">
260
- Total number of images: <span class="total">0</span><br/>
261
- Images processed: <span class="processed">0</span><br/>
262
- <!--Could not process: <span class="errors">0</span> Images<br/>-->
263
- </div>
264
- <!--Dropdown-->
265
- <h3>Select a period</h3>
266
- <select name="period" id="rta_period">
267
- <!--get all the images in the database-->
268
- <option value="0">All</option>
269
- <option value="1">Past Day</option>
270
- <option value="2">Past Week</option>
271
- <option value="3">Past Month</option>
272
- <option value="4">Between Dates</option>
273
- </select>
274
- <div class="fromTo hidden">
275
- <p><span>Start Date(including):<br/><input type="text" class="datepicker start" readonly /></span></p>
276
- <p><span>End Date(including):<br/><input type="text" class="datepicker end" readonly /></span></p>
277
- </div>
278
- <p class="submit">
279
- <button class="button button-primary RTA">Regenerate Thumbnails</button>
280
- <div class="wrap">
281
- <h3>Progress</h3>
282
- <div class="logstatus ui-widget-content">
283
- Nothing processed yet
284
- </div>
285
- </div><!--where the errors show -->
286
- <div class="wrap">
287
- <h3> Errors</h3>
288
- <div class="errors ui-widget-content">
289
- No errors to display yet
290
- </div><!-- where the errors show -->
291
- </p>
292
- </div>
293
  <?php
294
  $rotf = get_option( 'rtaOTF');
295
  ?>
@@ -333,7 +300,7 @@ function test_image_downsize($bool,$imgid,$size){
333
  $meta = wp_get_attachment_metadata($imgid);
334
  //get the path to the image
335
  if(isset($meta['file']) && !empty($meta['file'])){
336
- $fullsizepath = wp_upload_dir()['path'].$meta['file'];
337
  }
338
  // replace the main image with the thumb image name
339
  // $upload_dir = str_replace($meta['file'],$meta['sizes']['rtatest']['file'],$upload_dir);
@@ -368,9 +335,10 @@ if(!isset($meta['sizes'][$size]) && !empty($meta['sizes'][$size])){
368
 
369
  add_action('init','rtaInit');
370
  function rtaInit(){
 
 
371
  $rotf = get_option( 'rtaOTF');
372
  if ( ! function_exists( 'gambit_otf_regen_thumbs_media_downsize' ) && $rotf=='checked') {
373
-
374
  add_filter( 'image_downsize', 'gambit_otf_regen_thumbs_media_downsize', 10, 3 );
375
 
376
  /**
@@ -514,5 +482,11 @@ function rtaInit(){
514
  return false;
515
  }
516
  }
517
-
 
 
 
 
 
 
518
  }
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: 1.0.1
7
  Author: turcuciprian
8
  Author URI: http://turcuciprian.com
9
  License: GPLv2 or later
11
  */
12
 
13
  //Global variables for arguments
14
+
15
  class cc {
16
 
17
  // create basic page in the admin panel, with menu settings too
27
 
28
  public function ajaxOtfCallback() {
29
  if (isset($_POST['otfVal'])) {
30
+ $tempValue = '';
31
+ if(!empty($_POST['tempValue'])){
32
  $tempValue = $_POST['tempValue'];
33
+ }
34
+
35
+ update_option('rtaOTF', $tempValue);
36
+ echo "updated!";
37
  }
38
  }
39
 
232
  }
233
 
234
  function enqueue_admin($hook) {
235
+ if (isset($_GET['page']) && isset($hook)) {
236
  if ($_GET['page'] !== 'regenerate_thumbnails_advanced' && $hook != 'options-general.php ') {
237
  return;
238
  }
256
  <p>If there is a error in the page (most likely caused by another plugin or even the theme, the regenerate thumbnails advanced plugin will not work properly. Please fix this issue and come back here. YOU WILL NOT SEE THIS WARNING IF EVERYTHING IS WORKING FINE</p>
257
  </div>
258
  <div id="js-works" class="hidden">
259
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  <?php
261
  $rotf = get_option( 'rtaOTF');
262
  ?>
300
  $meta = wp_get_attachment_metadata($imgid);
301
  //get the path to the image
302
  if(isset($meta['file']) && !empty($meta['file'])){
303
+ $fullsizepath = wp_upload_dir().$meta['path'].$meta['file'];
304
  }
305
  // replace the main image with the thumb image name
306
  // $upload_dir = str_replace($meta['file'],$meta['sizes']['rtatest']['file'],$upload_dir);
335
 
336
  add_action('init','rtaInit');
337
  function rtaInit(){
338
+ add_image_size('test3',400,400);
339
+
340
  $rotf = get_option( 'rtaOTF');
341
  if ( ! function_exists( 'gambit_otf_regen_thumbs_media_downsize' ) && $rotf=='checked') {
 
342
  add_filter( 'image_downsize', 'gambit_otf_regen_thumbs_media_downsize', 10, 3 );
343
 
344
  /**
482
  return false;
483
  }
484
  }
485
+ }
486
+ add_action('wp_head','wpinittest');
487
+ function wpinittest(){
488
+ // echo wp_get_attachment_image( 5,'test3' );
489
+ $rotf = get_option( 'rtaOTF');
490
+ echo $rotf."xxxxxxxxxx";
491
+ exit;
492
  }
script.js CHANGED
@@ -4,207 +4,26 @@ jQuery(document).ready(function ($) {
4
  $('#js-works').removeClass('hidden');
5
 
6
  //the main script
7
- var err_arr = [];
8
- var errors_obj = $('#rta .errors');
9
- var pbar = $("#rta #progressbar");
10
  var rtaOtf = $('.rtaOtf');
11
  if(rtaOtf[0]){
12
  rtaOtf.click(function(){
13
- otfAjaxRequest($(this).attr('checked'));
14
- });
15
- }
16
- // if the progressbar id exists
17
- if (pbar[0]) {
18
- // set the initial value to 0
19
- pbar.progressbar({
20
- value: 0
21
- });
22
- }
23
- var rta_butt = $('.button.RTA');
24
- var rtaOtf = $('.rtaOtf');
25
-
26
- var period = $('#rta_period');
27
- var fromTo = $('.fromTo');
28
- if (period[0] && fromTo[0]) {
29
- var datepickerInputs = $('.datepicker');
30
- if (datepickerInputs[0]) {
31
- datepickerInputs.datepicker({
32
- onSelect: function (valTo) {//min/max dates set
33
- var dateStart = $('.datepicker.start');
34
- var dateEnd = $('.datepicker.end');
35
- if ($(this).hasClass('start')) {
36
- dateEnd.datepicker("change", {minDate: valTo});
37
- } else {
38
- dateStart.datepicker("change", {maxDate: valTo});
39
- }
40
- }
41
- });
42
- }
43
- period.change(function (value) {
44
- //if the date from-to option is selected
45
- if (parseInt($(this).val()) === 4) {
46
- fromTo.removeClass('hidden');//show the fields
47
- } else {
48
- fromTo.addClass('hidden');//Hide fields / keep the fields hidden
49
- }
50
- });
51
  }
52
 
53
- if (rta_butt[0]) {
54
- var logstatus = $('#rta .logstatus');
55
- var errstatus = $('#rta .errors');
56
 
57
- rta_butt.click(submit_ajax_call);
58
- //
59
- //LOOP REQUEST ... ajax request to call when the button is pressed
60
- //
61
- function submit_ajax_call() {
62
- logstatus.html('Processing...');
63
- errstatus.html('Processing...');
64
- err_arr = [];
65
- var period = $('#rta_period');
66
- var startTime = new Date().getTime();
67
-
68
- var dateStart = $('.datepicker.start');
69
- var dateEnd = $('.datepicker.end');
70
- var fromTo = '';
71
- if (dateStart.val() !== '' || dateEnd.val() !== '') {
72
- fromTo = dateStart.val() + '-' + dateEnd.val();
73
- }
74
-
75
- // First Time Request
76
- loop_ajax_request('general', 0, -1, period.val(), startTime, fromTo);
77
-
78
-
79
- }
80
- //
81
- //
82
- // Main ajax call
83
- //
84
- //
85
- function loop_ajax_request(type, offset, tCount, period, startTime, fromTo) {
86
-
87
- //tha ajax data
88
- var data = {
89
- 'action': 'rta_ajax',
90
- 'type': type,
91
- 'startTime': startTime,
92
- 'period': period,
93
- 'offset': offset,
94
- 'fromTo': fromTo
95
- };
96
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
97
- $.post(ajaxurl, data, function (response) {
98
-
99
- //var err_arr = new Array();
100
- //json response
101
- var json = JSON.parse(response);
102
- // console.log(json);
103
- var startTime = json.startTime;
104
- var offset = 0;
105
- var tCount = 0;
106
- var rta_total = $('#rta .info .total');
107
- var type = json.type;
108
-
109
- switch (type) {
110
- case 'general':
111
- var period = $('#rta_period');
112
- var rta_total = $('#rta .info .total');
113
- var rta_processed = $('#rta .info .processed');
114
- if (rta_total[0]) {
115
- var json = JSON.parse(response);
116
- rta_total.html(json.pCount);
117
- rta_processed.html("0");
118
- }
119
-
120
- if (rta_total[0]) {
121
- tCount = rta_total.html();
122
- }
123
- var startTime = new Date().getTime();
124
- var fromTo = json.fromTo;
125
- loop_ajax_request('submit', offset, tCount, json.period, startTime, fromTo);
126
-
127
- break;
128
- case 'submit':
129
- if (rta_total[0]) {
130
- tCount = rta_total.html();
131
- }
132
- var processed = $('#rta .info .processed');
133
-
134
- var progressbar_percentage = $('#progressbar .progress-label');
135
- if (processed[0] && rta_total.html() != 0) {
136
- processed.html(json.offset);
137
- }
138
- tCount = parseInt(tCount);
139
- response = parseInt(json.offset);
140
- if (tCount >= response) {
141
- offset = response;
142
- var lPercentage = offset / tCount * 100;
143
- if (pbar[0]) {
144
- if (progressbar_percentage[0]) {
145
- }
146
- // set the initial value to 0
147
- pbar.progressbar({
148
- value: lPercentage
149
- });
150
- lPercentage = Math.floor(lPercentage) + '%';
151
- progressbar_percentage.html(lPercentage);
152
- }
153
- var processTime = new Date().getTime() - startTime;
154
- processTime = processTime / 1000;
155
- //Add to log
156
- var logstatus = $('#rta .logstatus');
157
- if (json.logstatus !== null && logstatus[0]) {
158
- logstatus.append(json.logstatus + ' - in ' + processTime + ' seconds');
159
- }
160
- //call function again
161
- if (tCount > response) {
162
- //append unique errors
163
- unique_arr_append(json.error);
164
- //make a new request to the ajax call
165
- var startTime = new Date().getTime();
166
- fromTo = json.fromTo;
167
- loop_ajax_request(type, offset, tCount, json.period, startTime, fromTo);
168
- } else {
169
- console.log('Processing Completed!');
170
- var errStatus = $('#rta .errors');
171
- var logstatus = $('#rta .logstatus');
172
- logstatus.append('<br/>Completed !')
173
- if (errStatus.html() == "Processing...") {
174
- errStatus.html('No Errors.');
175
- }
176
- //the loop ended show errors and messages
177
- $.each(err_arr, function (index, value) {
178
- var final_val = '<div class="ui-state-error">' + value + '</div>';
179
- errors_obj.html(errors_obj.html() + final_val);
180
- });
181
-
182
- }
183
- } else {
184
- unique_arr_append(json.error);
185
- //the loop ended show errors and messages
186
- $.each(err_arr, function (index, value) {
187
- var final_val = '<div class="ui-state-error">' + value + '</div>';
188
- errors_obj.html(errors_obj.html() + final_val);
189
- });
190
- }
191
- break;
192
- }
193
- });
194
- }
195
  //OTF ajax call
196
- function otfAjaxRequest(tempValue) {
197
-
198
  //tha ajax data
199
  var data = {
200
  'action': 'rtaOtfAjax',
201
- 'tempValue': tempValue,
202
  'otfVal': 1
203
  };
204
  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
205
  $.post(ajaxurl, data, function (response) {
206
  console.log(response);
207
-
208
  });
209
  }
210
  // Append only unique array values
@@ -230,5 +49,4 @@ jQuery(document).ready(function ($) {
230
  }
231
 
232
  }
233
- }
234
  });
4
  $('#js-works').removeClass('hidden');
5
 
6
  //the main script
 
 
 
7
  var rtaOtf = $('.rtaOtf');
8
  if(rtaOtf[0]){
9
  rtaOtf.click(function(){
10
+ otfAjaxRequest($(this).attr('checked'));
11
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
 
 
 
 
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  //OTF ajax call
16
+ function otfAjaxRequest(tempVal) {
 
17
  //tha ajax data
18
  var data = {
19
  'action': 'rtaOtfAjax',
20
+ 'tempValue': tempVal,
21
  'otfVal': 1
22
  };
23
  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
24
  $.post(ajaxurl, data, function (response) {
25
  console.log(response);
26
+
27
  });
28
  }
29
  // Append only unique array values
49
  }
50
 
51
  }
 
52
  });