Resize Image After Upload - Version 1.7.1

Version Description

Release date: 26th February 2015

  • [Update] After reports of the plugin resizing PDF files, added check to ensure the plugin only attempts a resize on JPEG, GIF, and PNG file types other than relying on the response from WP_Image_Editor.
Download this release

Release Info

Developer jepsonrae
Plugin Icon 128x128 Resize Image After Upload
Version 1.7.1
Comparing to
See all releases

Code changes from version 1.7 to 1.7.1

Files changed (3) hide show
  1. icon-128x128.png +0 -0
  2. readme.txt +16 -8
  3. resize-image-after-upload.php +12 -5
icon-128x128.png CHANGED
Binary file
readme.txt CHANGED
@@ -1,24 +1,26 @@
1
  === Resize Image After Upload ===
2
  Contributors: iamphilrae
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3W4M254AA3KZG
4
- Tags: image, processing, plugin, resize, upload, resizing, optimization, optimize, optimise, optimisation, downsize
5
  Requires at least: 3.5
6
- Tested up to: 4.1
7
- Stable tag: 1.7
8
 
9
- Simple plugin to automatically resize uploaded images to within specified maximum width and height. Also has option to force recompression of JPEGs.
10
 
11
  == Description ==
12
 
13
- This plugin automatically resizes uploaded images (JPEG, GIF, and PNG) to within a given maximum width and/or height to reduce server space usage. This may be necessary due to the fact that images from digital cameras and smartphones can now be over 10MB each due to higher megapixel counts.
14
 
15
  In addition, the plugin can force re-compression of uploaded JPEG images, regardless of whether they are resized or not.
16
 
17
- Note: the resizing/recompression process will discard the original uploaded file including EXIF data.
18
 
19
- This plugin is not intended to replace the WordPress add_image_size() function, but rather complement it. Use this plugin to ensure that no excessively large images are stored on your server, then use add_image_size() to create versions of the images suitable for positioning in your website theme.
20
 
21
- This plugin uses standard PHP image resizing functions and will require a high amount of memory (RAM) to be allocated to PHP in your php.ini file (e.g 512MB).
 
 
22
 
23
  == Installation ==
24
 
@@ -33,6 +35,12 @@ This plugin uses standard PHP image resizing functions and will require a high a
33
 
34
  == Changelog ==
35
 
 
 
 
 
 
 
36
  = 1.7 =
37
  This is a major under-the-hood release to change core workings of the plugin. The plugin still functions as normal, but the way in which it resizes images has now changed to use standard WordPress libraries. This means that should your server have better image processing libraries than the GD default (e.g. ImageMagick), then the resizing method should make use of them. This should improve the output of your resized images!
38
 
1
  === Resize Image After Upload ===
2
  Contributors: iamphilrae
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3W4M254AA3KZG
4
+ Tags: image, processing, plugin, resize, upload, resizing, optimization, optimize, optimise, optimisation, downsize, imsanity, bulk resize
5
  Requires at least: 3.5
6
+ Tested up to: 4.2.2
7
+ Stable tag: 1.7.1
8
 
9
+ Behind-the-scenes plugin to automatically resize images when uploaded, restricting size to within specified maximum h/w. Uses standard WP functions.
10
 
11
  == Description ==
12
 
13
+ This plugin automatically resizes images (JPEG, GIF, and PNG) when they are uploaded to within a given maximum width and/or height to reduce server space usage. This may be necessary due to the fact that images from digital cameras and smartphones can now be over 10MB each due to higher megapixel counts.
14
 
15
  In addition, the plugin can force re-compression of uploaded JPEG images, regardless of whether they are resized or not.
16
 
17
+ **NOTE 1** - This plugin will *not* resize images that have already been uploaded.
18
 
19
+ **NOTE 2** - The resizing/recompression process will discard the original uploaded file including EXIF data.
20
 
21
+ This plugin is not intended to replace the WordPress *add_image_size()* function, but rather complement it. Use this plugin to ensure that no excessively large images are stored on your server, then use *add_image_size()* to create versions of the images suitable for positioning in your website theme.
22
+
23
+ This plugin uses standard WordPress image resizing functions and will require a high amount of memory (RAM) to be allocated to PHP in your php.ini file (e.g 512MB).
24
 
25
  == Installation ==
26
 
35
 
36
  == Changelog ==
37
 
38
+ = 1.7.1 =
39
+
40
+ Release date: 26th February 2015
41
+
42
+ * [Update] After reports of the plugin resizing PDF files, added check to ensure the plugin only attempts a resize on JPEG, GIF, and PNG file types other than relying on the response from WP_Image_Editor.
43
+
44
  = 1.7 =
45
  This is a major under-the-hood release to change core workings of the plugin. The plugin still functions as normal, but the way in which it resizes images has now changed to use standard WordPress libraries. This means that should your server have better image processing libraries than the GD default (e.g. ImageMagick), then the resizing method should make use of them. This should improve the output of your resized images!
46
 
resize-image-after-upload.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Resize Image After Upload
4
  Plugin URI: https://wordpress.org/plugins/resize-image-after-upload/
5
  Description: Simple plugin to automatically resize uploaded images to within specified maximum width and height. Also has option to force recompression of JPEGs. Configuration options found under <a href="options-general.php?page=resize-after-upload">Settings > Resize Image Upload</a>
6
  Author: iamphilrae
7
- Version: 1.7
8
  Author URI: http://www.philr.ae/
9
 
10
  Copyright (C) 2015 iamphilrae
@@ -24,7 +24,7 @@ along with this program; if not, write to the Free Software
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
- $PLUGIN_VERSION = '1.7';
28
  $DEBUG_LOGGER = false;
29
 
30
 
@@ -376,8 +376,16 @@ function jr_uploadresize_resize($image_data){
376
 
377
  if($resizing_enabled || $force_jpeg_recompression) {
378
 
 
 
 
379
  if(empty($image_data['file']) || empty($image_data['type'])) {
380
- return $image_data;
 
 
 
 
 
381
  }
382
 
383
  jr_error_log("--filename-( ".$image_data['file']." )");
@@ -385,10 +393,9 @@ function jr_uploadresize_resize($image_data){
385
  $image_type = $image_data['type'];
386
 
387
 
388
- if(is_wp_error($image_editor)) {
389
  jr_error_log("--wp-error-reported");
390
  }
391
-
392
  else {
393
 
394
  $to_save = false;
4
  Plugin URI: https://wordpress.org/plugins/resize-image-after-upload/
5
  Description: Simple plugin to automatically resize uploaded images to within specified maximum width and height. Also has option to force recompression of JPEGs. Configuration options found under <a href="options-general.php?page=resize-after-upload">Settings > Resize Image Upload</a>
6
  Author: iamphilrae
7
+ Version: 1.7.1
8
  Author URI: http://www.philr.ae/
9
 
10
  Copyright (C) 2015 iamphilrae
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
+ $PLUGIN_VERSION = '1.7.1';
28
  $DEBUG_LOGGER = false;
29
 
30
 
376
 
377
  if($resizing_enabled || $force_jpeg_recompression) {
378
 
379
+ $fatal_error_reported = false;
380
+ $valid_types = array('image/gif','image/png','image/jpeg','image/jpg');
381
+
382
  if(empty($image_data['file']) || empty($image_data['type'])) {
383
+ jr_error_log("--non-data-in-file-( ".print_r($image_data, true)." )");
384
+ $fatal_error_reported = true;
385
+ }
386
+ else if(!in_array($image_data['type'], $valid_types)) {
387
+ jr_error_log("--non-image-type-uploaded-( ".$image_data['type']." )");
388
+ $fatal_error_reported = true;
389
  }
390
 
391
  jr_error_log("--filename-( ".$image_data['file']." )");
393
  $image_type = $image_data['type'];
394
 
395
 
396
+ if($fatal_error_reported || is_wp_error($image_editor)) {
397
  jr_error_log("--wp-error-reported");
398
  }
 
399
  else {
400
 
401
  $to_save = false;