Version Description
- Error management if webservice not reachable
- Filesize limitation increased from 2MB to 5MB
Download this release
Release Info
Developer | maecia |
Plugin | reSmush.it Image Optimizer |
Version | 0.1.5 |
Comparing to | |
See all releases |
Code changes from version 0.1.4 to 0.1.5
- classes/resmushit.class.php +21 -1
- js/script.js +16 -5
- readme.txt +5 -1
- resmushit.php +14 -10
- resmushit.settings.php +1 -1
classes/resmushit.class.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
*/
|
11 |
Class reSmushit {
|
12 |
|
13 |
-
const MAX_FILESIZE =
|
14 |
|
15 |
/**
|
16 |
*
|
@@ -114,6 +114,8 @@ Class reSmushit {
|
|
114 |
|
115 |
//Regenerate thumbnails
|
116 |
wp_generate_attachment_metadata($attachment_id, get_attached_file( $attachment_id ));
|
|
|
|
|
117 |
}
|
118 |
|
119 |
|
@@ -372,4 +374,22 @@ Class reSmushit {
|
|
372 |
return $attachmentQuality[0];
|
373 |
return null;
|
374 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
}
|
10 |
*/
|
11 |
Class reSmushit {
|
12 |
|
13 |
+
const MAX_FILESIZE = 5242880;
|
14 |
|
15 |
/**
|
16 |
*
|
114 |
|
115 |
//Regenerate thumbnails
|
116 |
wp_generate_attachment_metadata($attachment_id, get_attached_file( $attachment_id ));
|
117 |
+
|
118 |
+
return self::wasSuccessfullyUpdated( $attachment_id );
|
119 |
}
|
120 |
|
121 |
|
374 |
return $attachmentQuality[0];
|
375 |
return null;
|
376 |
}
|
377 |
+
|
378 |
+
|
379 |
+
|
380 |
+
/**
|
381 |
+
*
|
382 |
+
* Check if this Attachment was successfully optimized
|
383 |
+
*
|
384 |
+
* @param int $attachment_id Post ID
|
385 |
+
* @return string $status
|
386 |
+
*/
|
387 |
+
public static function wasSuccessfullyUpdated($attachment_id){
|
388 |
+
if(self::getDisabledState( $attachment_id ))
|
389 |
+
return 'disabled';
|
390 |
+
|
391 |
+
if( self::getPictureQualitySetting() != self::getAttachmentQuality( $attachment_id ))
|
392 |
+
return 'failed';
|
393 |
+
return 'success';
|
394 |
+
}
|
395 |
}
|
js/script.js
CHANGED
@@ -27,13 +27,17 @@ optimizeSingleAttachment();
|
|
27 |
/**
|
28 |
* recursive function for resizing images
|
29 |
*/
|
30 |
-
function resmushit_bulk_process(bulk, item){
|
|
|
31 |
jQuery.post(
|
32 |
-
ajaxurl, {
|
33 |
action: 'resmushit_bulk_process_image',
|
34 |
data: bulk[item]
|
35 |
},
|
36 |
function(response) {
|
|
|
|
|
|
|
37 |
if(!flag_removed){
|
38 |
jQuery('#bulk_resize_target').remove();
|
39 |
container.append('<div id="smush_results" style="padding: 20px 5px; overflow: auto;" />');
|
@@ -49,9 +53,16 @@ function resmushit_bulk_process(bulk, item){
|
|
49 |
if(item < bulk.length - 1)
|
50 |
resmushit_bulk_process(bulk, item + 1);
|
51 |
else{
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
}
|
57 |
);
|
27 |
/**
|
28 |
* recursive function for resizing images
|
29 |
*/
|
30 |
+
function resmushit_bulk_process(bulk, item){
|
31 |
+
var error_occured = false;
|
32 |
jQuery.post(
|
33 |
+
ajaxurl, {
|
34 |
action: 'resmushit_bulk_process_image',
|
35 |
data: bulk[item]
|
36 |
},
|
37 |
function(response) {
|
38 |
+
if(response == 'failed')
|
39 |
+
error_occured = true;
|
40 |
+
|
41 |
if(!flag_removed){
|
42 |
jQuery('#bulk_resize_target').remove();
|
43 |
container.append('<div id="smush_results" style="padding: 20px 5px; overflow: auto;" />');
|
53 |
if(item < bulk.length - 1)
|
54 |
resmushit_bulk_process(bulk, item + 1);
|
55 |
else{
|
56 |
+
if(error_occured){
|
57 |
+
jQuery('.non-optimized-wrapper h3').text('An error occured when contacting webservice. Please try again later.');
|
58 |
+
jQuery('.non-optimized-wrapper > p').remove();
|
59 |
+
jQuery('.non-optimized-wrapper > div').remove();
|
60 |
+
}
|
61 |
+
else{
|
62 |
+
jQuery('.non-optimized-wrapper').addClass('disabled');
|
63 |
+
jQuery('.optimized-wrapper').removeClass('disabled');
|
64 |
+
updateStatistics();
|
65 |
+
}
|
66 |
}
|
67 |
}
|
68 |
);
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: maecia
|
|
3 |
Tags: image, optimizer, image optimization, resmush.it, smush, jpg, png, gif, optimization, compression, Compress, Images, Pictures, Reduce Image Size, Smush, Smush.it
|
4 |
Requires at least: 4.0.0
|
5 |
Tested up to: 4.6.0
|
6 |
-
Stable tag: 0.1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -41,6 +41,10 @@ Yes ! Absolutely free, the only restriction is to send images below 5MB.
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
44 |
= 0.1.4 =
|
45 |
* CSS Fixes
|
46 |
|
3 |
Tags: image, optimizer, image optimization, resmush.it, smush, jpg, png, gif, optimization, compression, Compress, Images, Pictures, Reduce Image Size, Smush, Smush.it
|
4 |
Requires at least: 4.0.0
|
5 |
Tested up to: 4.6.0
|
6 |
+
Stable tag: 0.1.5
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 0.1.5 =
|
45 |
+
* Error management if webservice not reachable
|
46 |
+
* Filesize limitation increased from 2MB to 5MB
|
47 |
+
|
48 |
= 0.1.4 =
|
49 |
* CSS Fixes
|
50 |
|
resmushit.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
* Plugin Name: reSmush.it Image Optimizer
|
11 |
* Plugin URI: http://www.resmush.it
|
12 |
* Description: Image Optimization API. Provides image size optimization
|
13 |
-
* Version: 0.1.
|
14 |
* Timestamp: 2016.08.10
|
15 |
* Author: Maecia
|
16 |
* Author URI: https://www.maecia.com
|
@@ -80,6 +80,7 @@ function resmushit_process_images($attachments, $force_keep_original = TRUE) {
|
|
80 |
global $attachment_id;
|
81 |
$cumulated_original_sizes = 0;
|
82 |
$cumulated_optimized_sizes = 0;
|
|
|
83 |
|
84 |
if(reSmushit::getDisabledState($attachment_id))
|
85 |
return $attachments;
|
@@ -98,15 +99,18 @@ function resmushit_process_images($attachments, $force_keep_original = TRUE) {
|
|
98 |
$cumulated_original_sizes += $stat->src_size;
|
99 |
$cumulated_optimized_sizes += $stat->dest_size;
|
100 |
$count++;
|
101 |
-
}
|
|
|
102 |
}
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
|
|
|
|
110 |
}
|
111 |
return $attachments;
|
112 |
}
|
@@ -218,7 +222,7 @@ add_action( 'wp_ajax_resmushit_optimize_single_attachment', 'resmushit_optimize_
|
|
218 |
*/
|
219 |
function resmushit_bulk_process_image() {
|
220 |
rlog('Bulk optimization launched for file : ' . get_attached_file( sanitize_text_field($_POST['data']['ID']) ));
|
221 |
-
reSmushit::revert(sanitize_text_field($_POST['data']['ID']));
|
222 |
die();
|
223 |
}
|
224 |
add_action( 'wp_ajax_resmushit_bulk_process_image', 'resmushit_bulk_process_image' );
|
10 |
* Plugin Name: reSmush.it Image Optimizer
|
11 |
* Plugin URI: http://www.resmush.it
|
12 |
* Description: Image Optimization API. Provides image size optimization
|
13 |
+
* Version: 0.1.5
|
14 |
* Timestamp: 2016.08.10
|
15 |
* Author: Maecia
|
16 |
* Author URI: https://www.maecia.com
|
80 |
global $attachment_id;
|
81 |
$cumulated_original_sizes = 0;
|
82 |
$cumulated_optimized_sizes = 0;
|
83 |
+
$error = FALSE;
|
84 |
|
85 |
if(reSmushit::getDisabledState($attachment_id))
|
86 |
return $attachments;
|
99 |
$cumulated_original_sizes += $stat->src_size;
|
100 |
$cumulated_optimized_sizes += $stat->dest_size;
|
101 |
$count++;
|
102 |
+
} else
|
103 |
+
$error = TRUE;
|
104 |
}
|
105 |
+
if(!$error) {
|
106 |
+
$optimizations_successful_count = get_option('resmushit_total_optimized');
|
107 |
+
update_option( 'resmushit_total_optimized', $optimizations_successful_count + $count );
|
108 |
+
|
109 |
+
update_post_meta($attachment_id,'resmushed_quality', resmushit::getPictureQualitySetting());
|
110 |
+
if(get_option('resmushit_statistics')){
|
111 |
+
update_post_meta($attachment_id,'resmushed_cumulated_original_sizes', $cumulated_original_sizes);
|
112 |
+
update_post_meta($attachment_id,'resmushed_cumulated_optimized_sizes', $cumulated_optimized_sizes);
|
113 |
+
}
|
114 |
}
|
115 |
return $attachments;
|
116 |
}
|
222 |
*/
|
223 |
function resmushit_bulk_process_image() {
|
224 |
rlog('Bulk optimization launched for file : ' . get_attached_file( sanitize_text_field($_POST['data']['ID']) ));
|
225 |
+
echo reSmushit::revert(sanitize_text_field($_POST['data']['ID']));
|
226 |
die();
|
227 |
}
|
228 |
add_action( 'wp_ajax_resmushit_bulk_process_image', 'resmushit_bulk_process_image' );
|
resmushit.settings.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
|
4 |
define('RESMUSHIT_ENDPOINT', 'http://api.resmush.it/');
|
5 |
-
define('RESMUSHIT_VERSION', '0.1.
|
6 |
define('RESMUSHIT_DEFAULT_QLTY', '92');
|
7 |
define('RESMUSHIT_TIMEOUT', '5');
|
8 |
define('RESMUSHIT_LOGS_PATH', 'resmushit.log');
|
2 |
|
3 |
|
4 |
define('RESMUSHIT_ENDPOINT', 'http://api.resmush.it/');
|
5 |
+
define('RESMUSHIT_VERSION', '0.1.5');
|
6 |
define('RESMUSHIT_DEFAULT_QLTY', '92');
|
7 |
define('RESMUSHIT_TIMEOUT', '5');
|
8 |
define('RESMUSHIT_LOGS_PATH', 'resmushit.log');
|