Version Description
- fixed: bulk resizer scan returning incorrect results
- fixed: sprintf error during resizing and upload
Download this release
Release Info
Developer | nosilver4u |
Plugin | Imsanity |
Version | 2.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.4.0 to 2.4.1
- ajax.php +35 -16
- imsanity.php +12 -6
- readme.txt +8 -3
- settings.php +33 -20
ajax.php
CHANGED
@@ -14,16 +14,24 @@ add_action( 'wp_ajax_imsanity_resize_image', 'imsanity_resize_image' );
|
|
14 |
*/
|
15 |
function imsanity_verify_permission() {
|
16 |
if ( ! current_user_can( 'activate_plugins' ) ) { // this isn't a real capability, but super admins can do anything, so it works.
|
17 |
-
die(
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'imsanity-bulk' ) ) {
|
23 |
-
die(
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
}
|
29 |
|
@@ -48,6 +56,9 @@ function imsanity_get_images() {
|
|
48 |
while ( $images ) {
|
49 |
|
50 |
foreach ( $images as $image ) {
|
|
|
|
|
|
|
51 |
$meta = unserialize( $image->file_meta );
|
52 |
if ( imsanity_get_option( 'imsanity_deep_scan', false ) ) {
|
53 |
$file_path = imsanity_attachment_path( $meta, $image->ID, '', false );
|
@@ -94,10 +105,14 @@ function imsanity_resize_image() {
|
|
94 |
$id = (int) $_POST['id'];
|
95 |
|
96 |
if ( ! $id ) {
|
97 |
-
die(
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
$meta = wp_get_attachment_metadata( $id );
|
@@ -108,10 +123,14 @@ function imsanity_resize_image() {
|
|
108 |
if ( ! is_writable( $oldpath ) ) {
|
109 |
/* translators: %s: File-name of the image */
|
110 |
$msg = sprintf( esc_html__( '%s is not writable', 'imsanity' ), $oldpath );
|
111 |
-
die(
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
|
117 |
$maxw = imsanity_get_option( 'imsanity_max_width', IMSANITY_DEFAULT_MAX_WIDTH );
|
14 |
*/
|
15 |
function imsanity_verify_permission() {
|
16 |
if ( ! current_user_can( 'activate_plugins' ) ) { // this isn't a real capability, but super admins can do anything, so it works.
|
17 |
+
die(
|
18 |
+
json_encode(
|
19 |
+
array(
|
20 |
+
'success' => false,
|
21 |
+
'message' => esc_html__( 'Administrator permission is required', 'imsanity' ),
|
22 |
+
)
|
23 |
+
)
|
24 |
+
);
|
25 |
}
|
26 |
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'imsanity-bulk' ) ) {
|
27 |
+
die(
|
28 |
+
json_encode(
|
29 |
+
array(
|
30 |
+
'success' => false,
|
31 |
+
'message' => esc_html__( 'Access token has expired, please reload the page.', 'imsanity' ),
|
32 |
+
)
|
33 |
+
)
|
34 |
+
);
|
35 |
}
|
36 |
}
|
37 |
|
56 |
while ( $images ) {
|
57 |
|
58 |
foreach ( $images as $image ) {
|
59 |
+
$imagew = false;
|
60 |
+
$imageh = false;
|
61 |
+
|
62 |
$meta = unserialize( $image->file_meta );
|
63 |
if ( imsanity_get_option( 'imsanity_deep_scan', false ) ) {
|
64 |
$file_path = imsanity_attachment_path( $meta, $image->ID, '', false );
|
105 |
$id = (int) $_POST['id'];
|
106 |
|
107 |
if ( ! $id ) {
|
108 |
+
die(
|
109 |
+
json_encode(
|
110 |
+
array(
|
111 |
+
'success' => false,
|
112 |
+
'message' => esc_html__( 'Missing ID Parameter', 'imsanity' ),
|
113 |
+
)
|
114 |
+
)
|
115 |
+
);
|
116 |
}
|
117 |
|
118 |
$meta = wp_get_attachment_metadata( $id );
|
123 |
if ( ! is_writable( $oldpath ) ) {
|
124 |
/* translators: %s: File-name of the image */
|
125 |
$msg = sprintf( esc_html__( '%s is not writable', 'imsanity' ), $oldpath );
|
126 |
+
die(
|
127 |
+
json_encode(
|
128 |
+
array(
|
129 |
+
'success' => false,
|
130 |
+
'message' => $msg,
|
131 |
+
)
|
132 |
+
)
|
133 |
+
);
|
134 |
}
|
135 |
|
136 |
$maxw = imsanity_get_option( 'imsanity_max_width', IMSANITY_DEFAULT_MAX_WIDTH );
|
imsanity.php
CHANGED
@@ -12,9 +12,9 @@
|
|
12 |
Plugin Name: Imsanity
|
13 |
Plugin URI: https://wordpress.org/plugins/imsanity/
|
14 |
Description: Imsanity stops insanely huge image uploads
|
15 |
-
Author:
|
16 |
Text Domain: imsanity
|
17 |
-
Version: 2.4.
|
18 |
Author URI: https://ewww.io/
|
19 |
License: GPLv3
|
20 |
*/
|
@@ -23,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
23 |
exit;
|
24 |
}
|
25 |
|
26 |
-
define( 'IMSANITY_VERSION', '2.4.
|
27 |
define( 'IMSANITY_SCHEMA_VERSION', '1.1' );
|
28 |
|
29 |
define( 'IMSANITY_DEFAULT_MAX_WIDTH', 2048 );
|
@@ -181,16 +181,22 @@ function imsanity_handle_upload( $params ) {
|
|
181 |
}
|
182 |
} elseif ( false === $resizeresult ) {
|
183 |
return $params;
|
184 |
-
}
|
185 |
// resize didn't work, likely because the image processing libraries are missing.
|
186 |
// remove the old image so we don't leave orphan files hanging around.
|
187 |
unlink( $oldpath );
|
188 |
|
189 |
$params = wp_handle_upload_error(
|
190 |
$oldpath,
|
191 |
-
|
192 |
-
|
|
|
|
|
|
|
|
|
193 |
);
|
|
|
|
|
194 |
}
|
195 |
}
|
196 |
}
|
12 |
Plugin Name: Imsanity
|
13 |
Plugin URI: https://wordpress.org/plugins/imsanity/
|
14 |
Description: Imsanity stops insanely huge image uploads
|
15 |
+
Author: Exactly WWW
|
16 |
Text Domain: imsanity
|
17 |
+
Version: 2.4.1
|
18 |
Author URI: https://ewww.io/
|
19 |
License: GPLv3
|
20 |
*/
|
23 |
exit;
|
24 |
}
|
25 |
|
26 |
+
define( 'IMSANITY_VERSION', '2.4.1' );
|
27 |
define( 'IMSANITY_SCHEMA_VERSION', '1.1' );
|
28 |
|
29 |
define( 'IMSANITY_DEFAULT_MAX_WIDTH', 2048 );
|
181 |
}
|
182 |
} elseif ( false === $resizeresult ) {
|
183 |
return $params;
|
184 |
+
} elseif ( is_wp_error( $resizeresult ) ) {
|
185 |
// resize didn't work, likely because the image processing libraries are missing.
|
186 |
// remove the old image so we don't leave orphan files hanging around.
|
187 |
unlink( $oldpath );
|
188 |
|
189 |
$params = wp_handle_upload_error(
|
190 |
$oldpath,
|
191 |
+
sprintf(
|
192 |
+
/* translators: 1: error message 2: link to support forums */
|
193 |
+
esc_html__( 'Imsanity was unable to resize this image for the following reason: %1$s. If you continue to see this error message, you may need to install missing server components. If you think you have discovered a bug, please report it on the Imsanity support forum: %2$s', 'imsanity' ),
|
194 |
+
$resizeresult->get_error_message(),
|
195 |
+
'https://wordpress.org/support/plugin/imsanity'
|
196 |
+
)
|
197 |
);
|
198 |
+
} else {
|
199 |
+
return $params;
|
200 |
}
|
201 |
}
|
202 |
}
|
readme.txt
CHANGED
@@ -2,9 +2,10 @@
|
|
2 |
Contributors: nosilver4u,verysimple
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MKMQKCBFFG3WW
|
4 |
Tags: image, scale, resize, space saver, quality
|
5 |
-
Requires at least: 4.
|
6 |
-
Tested up to:
|
7 |
-
|
|
|
8 |
|
9 |
Imsanity automatically resizes huge image uploads. Are contributors uploading huge photos? Tired of manually scaling? Imsanity to the rescue!
|
10 |
|
@@ -128,6 +129,10 @@ Questions may be posted on the support forum at https://wordpress.org/support/pl
|
|
128 |
|
129 |
== Changelog ==
|
130 |
|
|
|
|
|
|
|
|
|
131 |
= 2.4.0 =
|
132 |
* added: deep scanning option for when attachment metadata isn't updating properly
|
133 |
* fixed: uploads from Gutenberg not detected properly
|
2 |
Contributors: nosilver4u,verysimple
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MKMQKCBFFG3WW
|
4 |
Tags: image, scale, resize, space saver, quality
|
5 |
+
Requires at least: 4.5
|
6 |
+
Tested up to: 5.0
|
7 |
+
Requires PHP: 5.6
|
8 |
+
Stable tag: 2.4.1
|
9 |
|
10 |
Imsanity automatically resizes huge image uploads. Are contributors uploading huge photos? Tired of manually scaling? Imsanity to the rescue!
|
11 |
|
129 |
|
130 |
== Changelog ==
|
131 |
|
132 |
+
= 2.4.1 =
|
133 |
+
* fixed: bulk resizer scan returning incorrect results
|
134 |
+
* fixed: sprintf error during resizing and upload
|
135 |
+
|
136 |
= 2.4.0 =
|
137 |
* added: deep scanning option for when attachment metadata isn't updating properly
|
138 |
* fixed: uploads from Gutenberg not detected properly
|
settings.php
CHANGED
@@ -72,14 +72,18 @@ function imsanity_queue_script( $hook ) {
|
|
72 |
}
|
73 |
// Register the scripts that are used by the bulk resizer.
|
74 |
wp_enqueue_script( 'imsanity_script', plugins_url( '/scripts/imsanity.js', __FILE__ ), array( 'jquery' ), IMSANITY_VERSION );
|
75 |
-
wp_localize_script(
|
76 |
-
'
|
77 |
-
'
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
|
85 |
/**
|
@@ -166,24 +170,33 @@ function imsanity_maybe_created_custom_table() {
|
|
166 |
|
167 |
// Add the rows to the database.
|
168 |
$data = imsanity_get_default_multisite_settings();
|
169 |
-
$wpdb->insert(
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
}
|
178 |
|
179 |
if ( IMSANITY_SCHEMA_VERSION != $schema ) {
|
180 |
// This is a schema update. for the moment there is only one schema update available, from 1.0 to 1.1.
|
181 |
if ( '1.0' == $schema ) {
|
182 |
// Update from version 1.0 to 1.1.
|
183 |
-
$wpdb->insert(
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
187 |
$wpdb->query( "ALTER TABLE $wpdb->imsanity_ms CHANGE COLUMN data data TEXT NOT NULL;" );
|
188 |
} else {
|
189 |
// @todo we don't have this yet
|
72 |
}
|
73 |
// Register the scripts that are used by the bulk resizer.
|
74 |
wp_enqueue_script( 'imsanity_script', plugins_url( '/scripts/imsanity.js', __FILE__ ), array( 'jquery' ), IMSANITY_VERSION );
|
75 |
+
wp_localize_script(
|
76 |
+
'imsanity_script',
|
77 |
+
'imsanity_vars',
|
78 |
+
array(
|
79 |
+
'_wpnonce' => wp_create_nonce( 'imsanity-bulk' ),
|
80 |
+
'resizing_complete' => esc_html__( 'Resizing Complete', 'imsanity' ),
|
81 |
+
'resize_selected' => esc_html__( 'Resize Selected Images', 'imsanity' ),
|
82 |
+
'image' => esc_html__( 'Image', 'imsanity' ),
|
83 |
+
'invalid_response' => esc_html__( 'Received an invalid response, please check for errors in the Developer Tools console of your browser.', 'imsanity' ),
|
84 |
+
'none_found' => esc_html__( 'There are no images that need to be resized.', 'imsanity' ),
|
85 |
+
)
|
86 |
+
);
|
87 |
}
|
88 |
|
89 |
/**
|
170 |
|
171 |
// Add the rows to the database.
|
172 |
$data = imsanity_get_default_multisite_settings();
|
173 |
+
$wpdb->insert(
|
174 |
+
$wpdb->imsanity_ms,
|
175 |
+
array(
|
176 |
+
'setting' => 'multisite',
|
177 |
+
'data' => maybe_serialize( $data ),
|
178 |
+
)
|
179 |
+
);
|
180 |
+
$wpdb->insert(
|
181 |
+
$wpdb->imsanity_ms,
|
182 |
+
array(
|
183 |
+
'setting' => 'schema',
|
184 |
+
'data' => IMSANITY_SCHEMA_VERSION,
|
185 |
+
)
|
186 |
+
);
|
187 |
}
|
188 |
|
189 |
if ( IMSANITY_SCHEMA_VERSION != $schema ) {
|
190 |
// This is a schema update. for the moment there is only one schema update available, from 1.0 to 1.1.
|
191 |
if ( '1.0' == $schema ) {
|
192 |
// Update from version 1.0 to 1.1.
|
193 |
+
$wpdb->insert(
|
194 |
+
$wpdb->imsanity_ms,
|
195 |
+
array(
|
196 |
+
'setting' => 'schema',
|
197 |
+
'data' => IMSANITY_SCHEMA_VERSION,
|
198 |
+
)
|
199 |
+
);
|
200 |
$wpdb->query( "ALTER TABLE $wpdb->imsanity_ms CHANGE COLUMN data data TEXT NOT NULL;" );
|
201 |
} else {
|
202 |
// @todo we don't have this yet
|