reGenerate Thumbnails Advanced - Version 1.1.2

Version Description

Download this release

Release Info

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

Code changes from version 1.1.1 to 1.1.2

trunk/README.md ADDED
@@ -0,0 +1,2 @@
 
 
1
+ # regenerate-thumbnails-advanced
2
+ Generates Thumbnails for the old uploaded images according to the theme required image sizes - advanced functionality
trunk/abExport.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $abError = false;
5
+ include_once ABSPATH.'wp-admin/includes/plugin.php';
6
+ if (!function_exists('ab_admin_notice_success')) {
7
+ if (!is_plugin_active('admin-builder/admin-builder.php')) {
8
+
9
+ function ab_admin_notice_success()
10
+ {
11
+ $pluginInstalled = false;
12
+ if (!function_exists('get_plugins')) {
13
+ require_once ABSPATH.'wp-admin/includes/plugin.php';
14
+ }
15
+ $allPlugins = get_plugins();
16
+ foreach ($allPlugins as $key => $value) {
17
+ if ($key === 'admin-builder/admin_builder.php') {
18
+ $pluginInstalled = true;
19
+ }
20
+ # code...
21
+ }
22
+ if (isset($_GET['action']) && $_GET['action'] === 'install-plugin' && isset($_GET['plugin']) && $_GET['plugin'] === 'admin-builder') {
23
+ return;
24
+ }
25
+ if ($pluginInstalled) {
26
+ //check if plugin is activated:
27
+ $abError = true;
28
+ $url = admin_url();
29
+
30
+ echo '<div class="notice notice-error is-dismissible">';
31
+ echo '<h3>Step 3(final): Activate Admin Builder!</h3>';
32
+ echo '<p>';
33
+ echo 'To get the full functionality , activate Admin Builder from the <a href="'.$url.'/plugins.php"><span class="button-primary">plugins directory</span></a>.';
34
+ echo '</p>';
35
+ echo '</div>';
36
+ //plugin is activated
37
+ } else {
38
+ $abError = true;
39
+ echo '<div class="notice notice-error is-dismissible">';
40
+ echo '<h3>Step 2: Install Admin Builder</h3>';
41
+ echo '<p>';
42
+ echo 'To get the full functionality , install Admin Builder.';
43
+ echo '</p>';
44
+ echo '<p>';
45
+ $plugin_name = 'admin-builder';
46
+ $install_link = '<a href="'.esc_url(network_admin_url('plugin-install.php?tab=plugin-information&amp;plugin='.$plugin_name.'&amp;TB_iframe=true&amp;width=600&amp;height=550')).'" class="thickbox" title="More info about '.$plugin_name.'"><span class="button-primary">Install '.$plugin_name.'</span></a>';
47
+
48
+ echo $install_link;
49
+ echo '</p>';
50
+ echo '</div>';
51
+ }
52
+ }
53
+ add_action('admin_notices', 'ab_admin_notice_success');
54
+ }
55
+ }
56
+ if (!$abError) {
57
+ if (!$abError) {
58
+ if (class_exists('loadFromPlugin')) {
59
+ $theJson = '{"menus":[{"label":"Posts","type":"post","name":"posts","unique":true,"children":[],"$$hashKey":"object:66"},{"label":"Pages","type":"page","name":"pages","unique":true,"children":[],"$$hashKey":"object:67"},{"label":"Reg. Thumbnails","type":"cPage","name":"regenerateThumbnailsAdvanced","unique":false,"children":[{"label":"General Settings","name":"tab1","context":"normal","priority":"default","fields":[{"name":"rtaOTF","type":"checkbox","label":"Auto Regenerate","description":"Check this if you want missing thumbnails to be created on the fly, when needed.","extraText":"Activate","$$hashKey":"object:293"}],"$$hashKey":"object:92"}],"capability":"manage_options","handler":"ab_regenerateThumbnailsAdvanced","pageTitle":"regenerate Thumbnails Settings","$$hashKey":"object:89","pageDescription":"Configure if you want to regenerate thumbnails on the fly or not. Just make sure to check the checkbox if you do want everything to be taken care of regarding unexisting plugins."}]}';
60
+ $lfp = new loadFromPlugin();
61
+ $lfp->load($theJson);
62
+ }
63
+ }
64
+ }
trunk/images/ui-bg_flat_30_cccccc_40x100.png ADDED
Binary file
trunk/images/ui-bg_flat_50_5c5c5c_40x100.png ADDED
Binary file
trunk/images/ui-bg_glass_20_555555_1x400.png ADDED
Binary file
trunk/images/ui-bg_glass_40_0078a3_1x400.png ADDED
Binary file
trunk/images/ui-bg_glass_40_ffc73d_1x400.png ADDED
Binary file
trunk/images/ui-bg_gloss-wave_25_333333_500x100.png ADDED
Binary file
trunk/images/ui-bg_highlight-soft_80_eeeeee_1x100.png ADDED
Binary file
trunk/images/ui-bg_inset-soft_25_000000_1x100.png ADDED
Binary file
trunk/images/ui-bg_inset-soft_30_f58400_1x100.png ADDED
Binary file
trunk/images/ui-icons_222222_256x240.png ADDED
Binary file
trunk/images/ui-icons_4b8e0b_256x240.png ADDED
Binary file
trunk/images/ui-icons_a83300_256x240.png ADDED
Binary file
trunk/images/ui-icons_cccccc_256x240.png ADDED
Binary file
trunk/images/ui-icons_ffffff_256x240.png ADDED
Binary file
trunk/readme.txt ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === reGenerate Thumbnails Advanced ===
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: 3.1
6
+ Tested up to: 4.4.1
7
+ Stable tag: 1.1.2
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Description: A plugin that makes regenerating thumbnails even easier than before and more flexible.
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.
18
+
19
+
20
+ Features:
21
+
22
+ * You can select a period in time for the images to be regenerated from
23
+ * The period is last day, last week, last month or all
24
+ * Clean simple interface where you have a progress bar showing you the percentage of images regenerated
25
+ * You get to see the total number of images affected by your period, as well as the images afected so far when processing
26
+ * Regenerate thubnails on the fly
27
+
28
+ == Installation ==
29
+
30
+ This section describes how to install the plugin and get it working.
31
+
32
+ e.g.
33
+
34
+ 1. Upload regenerate-thumbnails-advanced directory to the `/wp-content/plugins/` directory
35
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
36
+
37
+ == Frequently Asked Questions ==
38
+
39
+ = Can I regenerate just a few images =
40
+
41
+ You have the option to select from: all, past day, past week, past month
42
+
43
+ = What happens if I close the page and the script is loading? =
44
+
45
+ The script stops, it does not run in the background
46
+
47
+ == Screenshots ==
48
+
49
+ 1. The plugin page where it all happens
50
+
51
+
52
+ == Changelog ==
53
+
54
+ = 0.7 =
55
+ * The first upload of the plugin
56
+
57
+ = 0.8 =
58
+ *Shows errors
59
+ *GD library error missing library present
60
+ *added jquery ui images for
61
+ *added jquery ui min css file
62
+ *removed the incrementation of processed images if there are none (it was showing one was being processed when it wasn't)
63
+
64
+ = 0.8.1 =
65
+ *images did not get added in the previous version. Neither did the css file for jquery ui
66
+
67
+ = 0.8.2 =
68
+ *log section showing what's been processed (image name)
69
+
70
+ = 0.8.2.1 =
71
+ *Images processed gets updated on regenerate request (it was frozen before if no images where available to be processed)
72
+ *Added a extra image
73
+
74
+ = 0.8.2.2 =
75
+ *Added a "no js or js error" message to the page if it's the case
76
+
77
+ = 0.8.2.3 =
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
+ = 0.8.2.5 =
86
+ *Added Settings link in plugins info page
87
+ *Renamed submenu page to Regenerate Thumbnails under Settings
88
+
89
+ = 0.8.2.6 =
90
+ *Added the possibility to choose a start and end date from where to regenerate the thumbnails from
91
+ * Added new style
92
+ * Added datepickers
93
+
94
+ = 1.0 =
95
+ *Regenerate on the fly
96
+
97
+ = 1.0.1 =
98
+ Removed unnecesary functionality. Just the checkbox for OTF is now available.
99
+
100
+ = 1.0.2 =
101
+ Fixes a critical bug from the previous version
102
+
103
+ = 1.0.3 =
104
+ Added donate button
105
+
106
+ = 1.1 =
107
+ Added Admin builder plugin dependency and functionality.
108
+
109
+
110
+ == Upgrade Notice ==
111
+
112
+ = 0.7 =
113
+ No issues have been detected since this is the first version that's out there. Please report any issues
114
+
115
+ = 0.8 =
116
+ No issuse with this version that require attention
117
+
118
+ = 0.8.1 =
119
+ This is a very minor change . Practically fixing the previous change incomplete commit
120
+
121
+ = 0.8.2 =
122
+ No issuse with this version that require attention
123
+
124
+ = 0.8.2.1 =
125
+ No issuse with this version that require attention. Small update change
126
+
127
+ = 0.8.2.2 =
128
+ 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.
129
+
130
+ = 0.8.2.3 =
131
+ 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.
132
+
133
+ = 0.8.2.4 =
134
+ 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.
135
+
136
+ = 0.8.2.5 =
137
+ 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.
138
+
139
+ = 0.8.2.6 =
140
+ This version changes the style and adds a bit of functionality to the general settings (a date start-end option to choose from)
141
+
142
+ = 1.0 =
143
+ This version changes the style and adds a bit of functionality to the general settings (a date start-end option to choose from)
144
+
145
+ = 1.0.1 =
146
+ nothing that affect the previous data is changed. Update is save
147
+
148
+ = 1.0.2 =
149
+ nothing that affect the previous data is changed. Update is save
150
+
151
+ = 1.0.3 =
152
+ nothing that affect the previous data is changed. Update is save
153
+
154
+ = 1.1 =
155
+ Database field is saved someplace else now. It needs to be configured again. Basically just go into settings, click to activate and click save.
trunk/regenerate-thumbnails-advanced.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1.2
7
+ Author: turcuciprian
8
+ Author URI: http://turcuciprian.com
9
+ License: GPLv2 or later
10
+ Text Domain: RTA
11
+ */
12
+ include('abExport.php');
13
+
14
+ add_action('admin_enqueue_scripts', 'enqueue_admin');
15
+
16
+ function enqueue_admin($hook)
17
+ {
18
+ if (isset($_GET['page']) && isset($hook)) {
19
+ if ($_GET['page'] !== 'regenerate_thumbnails_advanced' && $hook != 'options-general.php ') {
20
+ return;
21
+ }
22
+ }
23
+ wp_enqueue_style('rta', plugin_dir_url(__FILE__).'style.css');
24
+ }
25
+
26
+ /* var @cc cc */
27
+
28
+ add_action('init', 'rtaInit');
29
+ function rtaInit()
30
+ {
31
+ global $abGen;
32
+ if (!function_exists($abGen,'getField')) {
33
+ return true;
34
+ }
35
+ $rotf = $abGen->getField('abOption_cPage_regenerateThumbnailsAdvanced', 'tab1', 'rtaOTF');
36
+ if (!function_exists('gambit_otf_regen_thumbs_media_downsize') && $rotf == 'on') {
37
+ add_filter('image_downsize', 'gambit_otf_regen_thumbs_media_downsize', 10, 3);
38
+
39
+ /**
40
+ * The downsizer. This only does something if the existing image size doesn't exist yet.
41
+ *
42
+ * @param $out boolean false
43
+ * @param $id int Attachment ID
44
+ * @param $size mixed The size name, or an array containing the width & height
45
+ *
46
+ * @return mixed False if the custom downsize failed, or an array of the image if successful
47
+ */
48
+ function gambit_otf_regen_thumbs_media_downsize($out, $id, $size)
49
+ {
50
+
51
+ // Gather all the different image sizes of WP (thumbnail, medium, large) and,
52
+ // all the theme/plugin-introduced sizes.
53
+ global $_gambit_otf_regen_thumbs_all_image_sizes;
54
+ if (!isset($_gambit_otf_regen_thumbs_all_image_sizes)) {
55
+ global $_wp_additional_image_sizes;
56
+
57
+ $_gambit_otf_regen_thumbs_all_image_sizes = array();
58
+ $interimSizes = get_intermediate_image_sizes();
59
+
60
+ foreach ($interimSizes as $sizeName) {
61
+ if (in_array($sizeName, array('thumbnail', 'medium', 'large'))) {
62
+ $_gambit_otf_regen_thumbs_all_image_sizes[ $sizeName ]['width'] = get_option($sizeName.'_size_w');
63
+ $_gambit_otf_regen_thumbs_all_image_sizes[ $sizeName ]['height'] = get_option($sizeName.'_size_h');
64
+ $_gambit_otf_regen_thumbs_all_image_sizes[ $sizeName ]['crop'] = (bool) get_option($sizeName.'_crop');
65
+ } elseif (isset($_wp_additional_image_sizes[ $sizeName ])) {
66
+ $_gambit_otf_regen_thumbs_all_image_sizes[ $sizeName ] = $_wp_additional_image_sizes[ $sizeName ];
67
+ }
68
+ }
69
+ }
70
+
71
+ // This now contains all the data that we have for all the image sizes
72
+ $allSizes = $_gambit_otf_regen_thumbs_all_image_sizes;
73
+
74
+ // If image size exists let WP serve it like normally
75
+ $imagedata = wp_get_attachment_metadata($id);
76
+
77
+ // Image attachment doesn't exist
78
+ if (!is_array($imagedata)) {
79
+ return false;
80
+ }
81
+
82
+ // If the size given is a string / a name of a size
83
+ if (is_string($size)) {
84
+
85
+ // If WP doesn't know about the image size name, then we can't really do any resizing of our own
86
+ if (empty($allSizes[ $size ])) {
87
+ return false;
88
+ }
89
+
90
+ // If the size has already been previously created, use it
91
+ if (!empty($imagedata['sizes'][ $size ]) && !empty($allSizes[ $size ])) {
92
+
93
+ // But only if the size remained the same
94
+ if ($allSizes[ $size ]['width'] == $imagedata['sizes'][ $size ]['width']
95
+ && $allSizes[ $size ]['height'] == $imagedata['sizes'][ $size ]['height']) {
96
+ return false;
97
+ }
98
+
99
+ // Or if the size is different and we found out before that the size really was different
100
+ if (!empty($imagedata['sizes'][ $size ][ 'width_query' ])
101
+ && !empty($imagedata['sizes'][ $size ]['height_query'])) {
102
+ if ($imagedata['sizes'][ $size ]['width_query'] == $allSizes[ $size ]['width']
103
+ && $imagedata['sizes'][ $size ]['height_query'] == $allSizes[ $size ]['height']) {
104
+ return false;
105
+ }
106
+ }
107
+ }
108
+
109
+ // Resize the image
110
+ $resized = image_make_intermediate_size(
111
+ get_attached_file($id),
112
+ $allSizes[ $size ]['width'],
113
+ $allSizes[ $size ]['height'],
114
+ $allSizes[ $size ]['crop']
115
+ );
116
+
117
+ // Resize somehow failed
118
+ if (!$resized) {
119
+ return false;
120
+ }
121
+
122
+ // Save the new size in WP
123
+ $imagedata['sizes'][ $size ] = $resized;
124
+
125
+ // Save some additional info so that we'll know next time whether we've resized this before
126
+ $imagedata['sizes'][ $size ]['width_query'] = $allSizes[ $size ]['width'];
127
+ $imagedata['sizes'][ $size ]['height_query'] = $allSizes[ $size ]['height'];
128
+
129
+ wp_update_attachment_metadata($id, $imagedata);
130
+
131
+ // Serve the resized image
132
+ $att_url = wp_get_attachment_url($id);
133
+
134
+ return array(dirname($att_url).'/'.$resized['file'], $resized['width'], $resized['height'], true);
135
+
136
+ // If the size given is a custom array size
137
+ } elseif (is_array($size)) {
138
+ $imagePath = get_attached_file($id);
139
+
140
+ // This would be the path of our resized image if the dimensions existed
141
+ $imageExt = pathinfo($imagePath, PATHINFO_EXTENSION);
142
+ $imagePath = preg_replace('/^(.*)\.'.$imageExt.'$/', sprintf('$1-%sx%s.%s', $size[0], $size[1], $imageExt), $imagePath);
143
+
144
+ $att_url = wp_get_attachment_url($id);
145
+
146
+ // If it already exists, serve it
147
+ if (file_exists($imagePath)) {
148
+ return array(dirname($att_url).'/'.basename($imagePath), $size[0], $size[1], true);
149
+ }
150
+
151
+ // If not, resize the image...
152
+ $resized = image_make_intermediate_size(
153
+ get_attached_file($id),
154
+ $size[0],
155
+ $size[1],
156
+ true
157
+ );
158
+
159
+ // Get attachment meta so we can add new size
160
+ $imagedata = wp_get_attachment_metadata($id);
161
+
162
+ // Save the new size in WP so that it can also perform actions on it
163
+ $imagedata['sizes'][ $size[0].'x'.$size[1] ] = $resized;
164
+ wp_update_attachment_metadata($id, $imagedata);
165
+
166
+ // Resize somehow failed
167
+ if (!$resized) {
168
+ return false;
169
+ }
170
+
171
+ // Then serve it
172
+ return array(dirname($att_url).'/'.$resized['file'], $resized['width'], $resized['height'], true);
173
+ }
174
+
175
+ return false;
176
+ }
177
+ }
178
+ }
trunk/screenshot-1.png ADDED
Binary file
trunk/style.css ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*Progress bar style*/
2
+ #rta .ui-progressbar{
3
+ position:relative;
4
+ }
5
+ #rta .ui-progressbar .ui-progressbar-value.ui-widget-header{
6
+ background-color: #34e749;
7
+ position:relative;
8
+ }
9
+ #rta .ui-progressbar .progress-label {
10
+ position: absolute;
11
+ left: 50%;
12
+ top: 4px;
13
+ font-weight: bold;
14
+ text-shadow: 1px 1px 0 #fff;
15
+ z-index: 10;
16
+ }
17
+ /*information section*/
18
+ #rta .info{
19
+ padding:20px 0;
20
+ line-height: 24px;
21
+ }
22
+ #rta .info span{
23
+ font-weight: bold;
24
+ font-size: 18px;
25
+ }
26
+ /*Errors style*/
27
+ #rta .errors,
28
+ #rta .logstatus{
29
+ float:left;
30
+ width:96%;
31
+ padding:10px;
32
+ margin:0px 1% 0 0;
33
+ text-align: left;
34
+ }
35
+ #rta .errors div{
36
+ margin:10px;
37
+ padding:5px 0 5px 10px;
38
+ }
39
+ #rta .errors div b{
40
+ font-size: 16px;
41
+ }
42
+ #rta .errors div.ui-state-error{
43
+ background:#cd0a0a;
44
+ }
45
+ #rta .hidden{
46
+ display:none;
47
+ }
48
+ #rta #no-js h1{
49
+ color:red;
50
+ text-align: center;
51
+ margin:140px 0 100px 0;
52
+ }#rta .wrap{
53
+ float:left;
54
+ width:46%;
55
+ }
56
+ #rta .otf{
57
+ display: inline-block;
58
+ margin:20px 0 0 0;
59
+ }