reGenerate Thumbnails Advanced - Version 1.4

Version Description

Added regenerate Thumbnails button to regenerate individual thumbnail

=

Download this release

Release Info

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

Code changes from version 1.3.3 to 1.4

Files changed (7) hide show
  1. images/ajax-loader.gif +0 -0
  2. mediaRows.php +45 -0
  3. readme.txt +8 -2
  4. regenerate-thumbnails-advanced.php +5 -4
  5. rest.php +3 -1
  6. script.js +144 -103
  7. style.css +43 -0
images/ajax-loader.gif ADDED
Binary file
mediaRows.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $mpRTA = new mediaPageRTA();
3
+
4
+ class mediaPageRTA
5
+ {
6
+ public function __construct()
7
+ {
8
+ //get the capability of the user for managing images
9
+ $this->capability = apply_filters('regenerate_thumbs_cap', 'manage_options');
10
+
11
+ //hook to the rows of the media page
12
+ add_filter('media_row_actions', array($this, 'addToMediaRow'), 10, 2);
13
+ add_action('admin_footer', array($this, 'admin_footer'), 10, 2);
14
+ }
15
+ //
16
+ //add an extra element to the media rows
17
+ //
18
+
19
+ //if the media type is not an image, don't add the element
20
+ public function addToMediaRow($actions, $post)
21
+ {
22
+ if ('image/' != substr($post->post_mime_type, 0, 6) || !current_user_can($this->capability)) {
23
+ return $actions;
24
+ }
25
+ $actions['regenerate_thumbnails'] = '<button type="button" class="rtaMediaRow" imgID="'.$post->ID.'">'.__('Regenerate Thumbnails', 'rta').'</button>';
26
+
27
+ return $actions;
28
+ }
29
+ public function admin_footer()
30
+ {
31
+ ?>
32
+ <div id="rta">
33
+ <div class="rtaPopup hidden">
34
+ <div class="child">
35
+ <img src="<?php echo plugin_dir_url( __FILE__ );?>images/ajax-loader.gif" alt="">
36
+ Regenerating Thumbnails
37
+ </div>
38
+
39
+ </div>
40
+ </div>
41
+
42
+ <?php
43
+
44
+ }
45
+ }
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.7.2
7
- Stable tag: 1.3.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,6 +12,9 @@ Description: A plugin that makes regenerating thumbnails even easier than before
12
 
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.
@@ -126,6 +129,9 @@ Removed donate button
126
  = 1.3.3 =
127
  Requests are being done trough REST API's now
128
 
 
 
 
129
  == Upgrade Notice ==
130
 
131
  = 0.7 =
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.7
7
+ Stable tag: 1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ High Level Tutorial:
16
+ https://www.youtube.com/watch?v=a5F5OsWZC28
17
+
18
  A plugin that makes regenerating thumbnails even easier than before and more flexible.
19
  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?
20
  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.
129
  = 1.3.3 =
130
  Requests are being done trough REST API's now
131
 
132
+ = 1.4 =
133
+ Added regenerate Thumbnails button to regenerate individual thumbnail
134
+
135
  == Upgrade Notice ==
136
 
137
  = 0.7 =
regenerate-thumbnails-advanced.php CHANGED
@@ -1,17 +1,18 @@
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: 1.3.3
7
  Author: turcuciprian
8
- Author URI: http://turcuciprian.com
9
  License: GPLv2 or later
10
  Text Domain: rta
11
  */
12
 
13
  //Global variables for arguments
14
  require_once("rest.php");
 
15
  class cc {
16
 
17
  // create basic page in the admin panel, with menu settings too
@@ -25,7 +26,7 @@ class cc {
25
  }
26
 
27
  public function ajax_callback() {
28
-
29
  }
30
 
31
  // Admin menu calback
1
  <?php
2
  /*
3
  Plugin Name: reGenerate Thumbnails - advanced
4
+ Plugin URI: http://ciprianturcu.com
5
  Description: A plugin that makes regenerating thumbnails even easier than before and more flexible.
6
+ Version: 1.4
7
  Author: turcuciprian
8
+ Author URI: http://ciprianturcu.com
9
  License: GPLv2 or later
10
  Text Domain: rta
11
  */
12
 
13
  //Global variables for arguments
14
  require_once("rest.php");
15
+ require_once("mediaRows.php");
16
  class cc {
17
 
18
  // create basic page in the admin panel, with menu settings too
26
  }
27
 
28
  public function ajax_callback() {
29
+
30
  }
31
 
32
  // Admin menu calback
rest.php CHANGED
@@ -149,7 +149,9 @@ class rtaREST
149
  while ($the_query->have_posts()) {
150
  $the_query->the_post();
151
  $image_id = $the_query->post->ID;
152
- $is_image = true;
 
 
153
  $fullsizepath = get_attached_file($image_id);
154
 
155
  //is image:
149
  while ($the_query->have_posts()) {
150
  $the_query->the_post();
151
  $image_id = $the_query->post->ID;
152
+ $is_image = true;if (isset($_POST['mediaID'])){
153
+ $image_id = $_POST['mediaID'];
154
+ }
155
  $fullsizepath = get_attached_file($image_id);
156
 
157
  //is image:
script.js CHANGED
@@ -1,99 +1,77 @@
1
  jQuery(document).ready(function($) {
 
 
2
  //no js error
3
  $('#no-js').addClass('hidden');
4
  $('#js-works').removeClass('hidden');
 
5
  //the main script
6
  var err_arr = [];
7
  var errors_obj = $('#rta .errors');
8
  var pbar = $("#rta #progressbar");
9
 
10
- // if the progressbar id exists
11
- if (pbar[0]) {
12
- // set the initial value to 0
13
- pbar.progressbar({
14
- value: 0
15
- });
16
- }
17
- var rta_butt = $('.button.RTA');
18
-
19
- var period = $('#rta_period');
20
- var fromTo = $('.fromTo');
21
- if (period[0] && fromTo[0]) {
22
- var datepickerInputs = $('.datepicker');
23
- if (datepickerInputs[0]) {
24
- datepickerInputs.datepicker({
25
- onSelect: function(valTo) { //min/max dates set
26
- var dateStart = $('.datepicker.start');
27
- var dateEnd = $('.datepicker.end');
28
- if ($(this).hasClass('start')) {
29
- dateEnd.datepicker("change", {
30
- minDate: valTo
31
- });
32
- } else {
33
- dateStart.datepicker("change", {
34
- maxDate: valTo
35
- });
36
- }
37
  }
38
- });
39
- }
40
- period.change(function(value) {
41
- //if the date from-to option is selected
42
- if (parseInt($(this).val()) === 4) {
43
- fromTo.removeClass('hidden'); //show the fields
44
- } else {
45
- fromTo.addClass('hidden'); //Hide fields / keep the fields hidden
46
  }
47
- });
48
- }
49
-
50
- if (rta_butt[0]) {
51
- var logstatus = $('#rta .logstatus');
52
- var errstatus = $('#rta .errors');
53
-
54
- //
55
- //LOOP REQUEST ... ajax request to call when the button is pressed
56
- //
57
- var submit_ajax_call = function() {
58
- logstatus.html('Processing...');
59
- errstatus.html('Processing...');
60
- err_arr = [];
61
- var period = $('#rta_period');
62
- var startTime = new Date().getTime();
63
-
64
- var dateStart = $('.datepicker.start');
65
- var dateEnd = $('.datepicker.end');
66
- var fromTo = '';
67
- if (dateStart.val() !== '' || dateEnd.val() !== '') {
68
- fromTo = dateStart.val() + '-' + dateEnd.val();
69
  }
 
 
70
 
71
- // First Time Request
72
- loop_ajax_request('general', 0, -1, period.val(), startTime, fromTo);
73
-
74
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  };
76
- rta_butt.click(submit_ajax_call);
77
-
78
- //
79
- //
80
- // Main ajax call
81
- //
82
- //
83
- var loop_ajax_request = function(type, offset, tCount, period, startTime, fromTo) {
84
- //tha ajax data
85
- var data = {
86
- 'type': type,
87
- 'startTime': startTime,
88
- 'period': period,
89
- 'offset': offset,
90
- 'fromTo': fromTo
91
- };
92
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
93
- $.post(rtaRestURL, data, function(response) {
94
- //var err_arr = new Array();
95
- //json response
96
- var json = response;
97
 
98
  var startTime = json.startTime;
99
  var offset = 0;
@@ -118,9 +96,9 @@ jQuery(document).ready(function($) {
118
  startTime = new Date().getTime();
119
  fromTo = json.fromTo;
120
  loop_ajax_request('submit', offset, tCount, json.period, startTime, fromTo);
121
-
122
  break;
123
  case 'submit':
 
124
  if (rta_total[0]) {
125
  tCount = rta_total.html();
126
  }
@@ -184,31 +162,94 @@ jQuery(document).ready(function($) {
184
  }
185
  break;
186
  }
 
 
187
 
188
- });
189
- };
190
- // Append only unique array values
191
- var unique_arr_append = function(val) {
192
- var unique = true;
193
- var i = 0;
194
- var y = 0;
195
- while (val[i]) {
196
- unique = true;
197
- y = 0;
198
- while (err_arr[y]) {
199
- if (err_arr[y] == val[i]) {
200
- // console.log(err_arr[i]);
201
- unique = false;
202
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
- y++;
205
- }
206
- if (unique) {
207
- err_arr.push(val[i]);
208
  }
209
- i++;
 
 
 
 
 
 
 
210
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  }
214
  });
1
  jQuery(document).ready(function($) {
2
+
3
+
4
  //no js error
5
  $('#no-js').addClass('hidden');
6
  $('#js-works').removeClass('hidden');
7
+ var rtaMediaRow = $('.rtaMediaRow');
8
  //the main script
9
  var err_arr = [];
10
  var errors_obj = $('#rta .errors');
11
  var pbar = $("#rta #progressbar");
12
 
13
+ // Append only unique array values
14
+ var unique_arr_append = function(val) {
15
+ var unique = true;
16
+ var i = 0;
17
+ var y = 0;
18
+ while (val[i]) {
19
+ unique = true;
20
+ y = 0;
21
+ while (err_arr[y]) {
22
+ if (err_arr[y] == val[i]) {
23
+ // console.log(err_arr[i]);
24
+ unique = false;
25
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
+ y++;
 
 
 
 
 
 
 
28
  }
29
+ if (unique) {
30
+ err_arr.push(val[i]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
+ i++;
33
+ }
34
 
35
+ };
36
+
37
+
38
+ //
39
+ //
40
+ // Main ajax call
41
+ //
42
+ //
43
+ var loop_ajax_request = function(type, offset, tCount, period, startTime, fromTo, mediaID) {
44
+ // console.log(type+'-first Run - type:'+type);
45
+ mediaID = (typeof mediaID !== "undefined" ? mediaID : null);
46
+ //tha ajax data
47
+ var data = {
48
+ 'type': type,
49
+ 'startTime': startTime,
50
+ 'period': period,
51
+ 'offset': offset,
52
+ 'fromTo': fromTo
53
  };
54
+ if (mediaID !== null) {
55
+ // console.log('MediaID!=null');
56
+ data.mediaID = mediaID;
57
+ }
58
+ // console.log('before post request start');
59
+ // console.log('rtaRestURL:'+rtaRestURL+' Data:');
60
+ // console.log(data);
61
+
62
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
63
+ $.post(rtaRestURL, data, function(response) {
64
+ if(mediaID!== null){
65
+ var rtaPopup = $('.rtaPopup');
66
+ if(rtaPopup[0]){
67
+ rtaPopup.addClass('hidden');
68
+ }
69
+ }
70
+ // console.log('after post request returned response');
71
+ // var err_arr = new Array();
72
+ //json response
73
+ var json = response;
74
+ // console.log(json);
75
 
76
  var startTime = json.startTime;
77
  var offset = 0;
96
  startTime = new Date().getTime();
97
  fromTo = json.fromTo;
98
  loop_ajax_request('submit', offset, tCount, json.period, startTime, fromTo);
 
99
  break;
100
  case 'submit':
101
+ // console.log(type+'-inside submit');
102
  if (rta_total[0]) {
103
  tCount = rta_total.html();
104
  }
162
  }
163
  break;
164
  }
165
+ });
166
+ };
167
 
168
+
169
+
170
+
171
+
172
+ // if the progressbar id exists
173
+ if (pbar[0]) {
174
+ // set the initial value to 0
175
+ pbar.progressbar({
176
+ value: 0
177
+ });
178
+ }
179
+ var rta_butt = $('.button.RTA');
180
+
181
+ var period = $('#rta_period');
182
+ var fromTo = $('.fromTo');
183
+ if (period[0] && fromTo[0]) {
184
+ var datepickerInputs = $('.datepicker');
185
+ if (datepickerInputs[0]) {
186
+ datepickerInputs.datepicker({
187
+ onSelect: function(valTo) { //min/max dates set
188
+ var dateStart = $('.datepicker.start');
189
+ var dateEnd = $('.datepicker.end');
190
+ if ($(this).hasClass('start')) {
191
+ dateEnd.datepicker("change", {
192
+ minDate: valTo
193
+ });
194
+ } else {
195
+ dateStart.datepicker("change", {
196
+ maxDate: valTo
197
+ });
198
  }
 
 
 
 
199
  }
200
+ });
201
+ }
202
+ period.change(function(value) {
203
+ //if the date from-to option is selected
204
+ if (parseInt($(this).val()) === 4) {
205
+ fromTo.removeClass('hidden'); //show the fields
206
+ } else {
207
+ fromTo.addClass('hidden'); //Hide fields / keep the fields hidden
208
  }
209
+ });
210
+ }
211
+
212
+ if (rta_butt[0]) {
213
+ var logstatus = $('#rta .logstatus');
214
+ var errstatus = $('#rta .errors');
215
+
216
+ //
217
+ //LOOP REQUEST ... ajax request to call when the button is pressed
218
+ //
219
+ var submit_ajax_call = function() {
220
+ logstatus.html('Processing...');
221
+ errstatus.html('Processing...');
222
+ err_arr = [];
223
+ var period = $('#rta_period');
224
+ var startTime = new Date().getTime();
225
+
226
+ var dateStart = $('.datepicker.start');
227
+ var dateEnd = $('.datepicker.end');
228
+ var fromTo = '';
229
+ if (dateStart.val() !== '' || dateEnd.val() !== '') {
230
+ fromTo = dateStart.val() + '-' + dateEnd.val();
231
+ }
232
+
233
+ // First Time Request
234
+ loop_ajax_request('general', 0, -1, period.val(), startTime, fromTo);
235
+
236
 
237
  };
238
+ rta_butt.click(submit_ajax_call);
239
+
240
+
241
+
242
+ }
243
+ if(rtaMediaRow[0]){
244
+ rtaMediaRow.click(function(){
245
+ var imgID = $(this).attr('imgID');
246
+ if(imgID){
247
+ var rtaPopup = $('.rtaPopup');
248
+ if(rtaPopup[0]){
249
+ rtaPopup.removeClass('hidden');
250
+ }
251
+ loop_ajax_request('submit', 0, 0, 0, 0, 0,imgID);
252
+ }
253
+ });
254
  }
255
  });
style.css CHANGED
@@ -70,3 +70,46 @@ body #rta .ui-progressbar .ui-progressbar-value.ui-widget-header {
70
  float: left;
71
  width: 46%;
72
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  float: left;
71
  width: 46%;
72
  }
73
+ .rtaPopup{
74
+ background:#000;
75
+ position: fixed;
76
+ color:#FFF;
77
+ top:0px;
78
+ bottom:0px;
79
+ left:0px;
80
+ right:0px;
81
+ opacity: 0.8;
82
+
83
+ /*Flexbox */
84
+ display: -ms-flexbox;
85
+ display: -webkit-flex;
86
+ display: flex;
87
+ -webkit-flex-direction: row;
88
+ -ms-flex-direction: row;
89
+ flex-direction: row;
90
+ -webkit-flex-wrap: nowrap;
91
+ -ms-flex-wrap: nowrap;
92
+ flex-wrap: nowrap;
93
+ -webkit-justify-content: center;
94
+ -ms-flex-pack: center;
95
+ justify-content: center;
96
+ -webkit-align-content: stretch;
97
+ -ms-flex-line-pack: stretch;
98
+ align-content: stretch;
99
+ -webkit-align-items: center;
100
+ -ms-flex-align: center;
101
+ align-items: center;
102
+ }
103
+
104
+
105
+ .rtaPopup .child{
106
+ -webkit-order: 0;
107
+ -ms-flex-order: 0;
108
+ order: 0;
109
+ -webkit-flex: 0 1 auto;
110
+ -ms-flex: 0 1 auto;
111
+ flex: 0 1 auto;
112
+ -webkit-align-self: auto;
113
+ -ms-flex-item-align: auto;
114
+ align-self: auto;
115
+ }