Imsanity - Version 2.8.2

Version Description

  • fixed: mime type error when filename in attachment metadata is incorrect
Download this release

Release Info

Developer nosilver4u
Plugin Icon 128x128 Imsanity
Version 2.8.2
Comparing to
See all releases

Code changes from version 2.8.1 to 2.8.2

Files changed (5) hide show
  1. .travis.yml +2 -0
  2. changelog.txt +3 -0
  3. imsanity.php +3 -3
  4. libs/utils.php +16 -6
  5. readme.txt +5 -2
.travis.yml CHANGED
@@ -13,6 +13,7 @@ branches:
13
  - master
14
 
15
  php:
 
16
  - 7.4
17
 
18
  env:
@@ -21,6 +22,7 @@ env:
21
  before_script:
22
  - export PATH="$HOME/.config/composer/vendor/bin:$PATH"
23
  - phpenv config-rm xdebug.ini
 
24
  - composer global require wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer phpcompatibility/phpcompatibility-wp
25
 
26
  script:
13
  - master
14
 
15
  php:
16
+ - 7.2
17
  - 7.4
18
 
19
  env:
22
  before_script:
23
  - export PATH="$HOME/.config/composer/vendor/bin:$PATH"
24
  - phpenv config-rm xdebug.ini
25
+ - composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
26
  - composer global require wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer phpcompatibility/phpcompatibility-wp
27
 
28
  script:
changelog.txt CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  = 2.8.1 =
2
  * changed: escape and sanitize more things
3
  * changed: tighten PHPCS rules used for pre-release testing
1
+ = 2.8.2 =
2
+ * fixed: mime type error when filename in attachment metadata is incorrect
3
+
4
  = 2.8.1 =
5
  * changed: escape and sanitize more things
6
  * changed: tighten PHPCS rules used for pre-release testing
imsanity.php CHANGED
@@ -14,10 +14,10 @@ Plugin URI: https://wordpress.org/plugins/imsanity/
14
  Description: Imsanity stops insanely huge image uploads
15
  Author: Exactly WWW
16
  Domain Path: /languages
17
- Version: 2.8.1
18
  Requires at least: 5.5
19
  Requires PHP: 7.2
20
- Author URI: https://ewww.io/
21
  License: GPLv3
22
  */
23
 
@@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
25
  exit;
26
  }
27
 
28
- define( 'IMSANITY_VERSION', '2.8.1' );
29
  define( 'IMSANITY_SCHEMA_VERSION', '1.1' );
30
 
31
  define( 'IMSANITY_DEFAULT_MAX_WIDTH', 1920 );
14
  Description: Imsanity stops insanely huge image uploads
15
  Author: Exactly WWW
16
  Domain Path: /languages
17
+ Version: 2.8.2
18
  Requires at least: 5.5
19
  Requires PHP: 7.2
20
+ Author URI: https://ewww.io/about/
21
  License: GPLv3
22
  */
23
 
25
  exit;
26
  }
27
 
28
+ define( 'IMSANITY_VERSION', '2.8.2' );
29
  define( 'IMSANITY_SCHEMA_VERSION', '1.1' );
30
 
31
  define( 'IMSANITY_DEFAULT_MAX_WIDTH', 1920 );
libs/utils.php CHANGED
@@ -206,26 +206,36 @@ function imsanity_resize_from_id( $id = 0 ) {
206
  );
207
  }
208
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  // Let folks filter the allowed mime-types for resizing.
210
- $allowed_types = apply_filters( 'imsanity_allowed_mimes', array( 'image/png', 'image/gif', 'image/jpeg' ), $meta['file'] );
211
  if ( is_string( $allowed_types ) ) {
212
  $allowed_types = array( $allowed_types );
213
  } elseif ( ! is_array( $allowed_types ) ) {
214
  $allowed_types = array();
215
  }
216
- $ftype = imsanity_quick_mimetype( $meta['file'] );
217
  if ( ! in_array( $ftype, $allowed_types, true ) ) {
218
  /* translators: %s: File type of the image */
219
- $msg = sprintf( esc_html__( '%1$s does not have an allowed file type (%2$s)', 'imsanity' ), $meta['file'], $ftype );
220
  return array(
221
  'success' => false,
222
  'message' => $msg,
223
  );
224
  }
225
 
226
- $uploads = wp_upload_dir();
227
- $oldpath = imsanity_attachment_path( $meta, $id, '', false );
228
- if ( empty( $oldpath ) || ! is_writable( $oldpath ) ) {
229
  /* translators: %s: File-name of the image */
230
  $msg = sprintf( esc_html__( '%s is not writable', 'imsanity' ), $meta['file'] );
231
  return array(
206
  );
207
  }
208
 
209
+ // $uploads = wp_upload_dir();
210
+ $oldpath = imsanity_attachment_path( $meta, $id, '', false );
211
+
212
+ if ( empty( $oldpath ) ) {
213
+ /* translators: %s: File-name of the image */
214
+ $msg = sprintf( esc_html__( 'Could not retrieve location of %s', 'imsanity' ), $meta['file'] );
215
+ return array(
216
+ 'success' => false,
217
+ 'message' => $msg,
218
+ );
219
+ }
220
+
221
  // Let folks filter the allowed mime-types for resizing.
222
+ $allowed_types = apply_filters( 'imsanity_allowed_mimes', array( 'image/png', 'image/gif', 'image/jpeg' ), $oldpath );
223
  if ( is_string( $allowed_types ) ) {
224
  $allowed_types = array( $allowed_types );
225
  } elseif ( ! is_array( $allowed_types ) ) {
226
  $allowed_types = array();
227
  }
228
+ $ftype = imsanity_quick_mimetype( $oldpath );
229
  if ( ! in_array( $ftype, $allowed_types, true ) ) {
230
  /* translators: %s: File type of the image */
231
+ $msg = sprintf( esc_html__( '%1$s does not have an allowed file type (%2$s)', 'imsanity' ), wp_basename( $oldpath ), $ftype );
232
  return array(
233
  'success' => false,
234
  'message' => $msg,
235
  );
236
  }
237
 
238
+ if ( ! is_writable( $oldpath ) ) {
 
 
239
  /* translators: %s: File-name of the image */
240
  $msg = sprintf( esc_html__( '%s is not writable', 'imsanity' ), $meta['file'] );
241
  return array(
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: nosilver4u
3
  Donate link: https://ewww.io/donate/
4
  Tags: image, scale, resize, space saver, quality, upload
5
  Requires at least: 5.5
6
- Tested up to: 6.0
7
  Requires PHP: 7.2
8
- Stable tag: 2.8.1
9
  License: GPLv3
10
 
11
  Imsanity automatically resizes huge image uploads. Are contributors uploading huge photos? Tired of manually resizing your images? Imsanity to the rescue!
@@ -106,6 +106,9 @@ Questions may be posted on the support forum at https://wordpress.org/support/pl
106
 
107
  == Changelog ==
108
 
 
 
 
109
  = 2.8.1 =
110
  * changed: escape and sanitize more things
111
  * changed: tighten PHPCS rules used for pre-release testing
3
  Donate link: https://ewww.io/donate/
4
  Tags: image, scale, resize, space saver, quality, upload
5
  Requires at least: 5.5
6
+ Tested up to: 6.1
7
  Requires PHP: 7.2
8
+ Stable tag: 2.8.2
9
  License: GPLv3
10
 
11
  Imsanity automatically resizes huge image uploads. Are contributors uploading huge photos? Tired of manually resizing your images? Imsanity to the rescue!
106
 
107
  == Changelog ==
108
 
109
+ = 2.8.2 =
110
+ * fixed: mime type error when filename in attachment metadata is incorrect
111
+
112
  = 2.8.1 =
113
  * changed: escape and sanitize more things
114
  * changed: tighten PHPCS rules used for pre-release testing