Resize Image After Upload - Version 1.2.0

Version Description

  • [Update] Now only runs images through the resizer if required (i.e. the image is actually larger than the max height/width).
Download this release

Release Info

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

Code changes from version 1.1.1 to 1.2.0

Files changed (2) hide show
  1. readme.txt +7 -4
  2. resize-image-after-upload.php +42 -19
readme.txt CHANGED
@@ -1,16 +1,16 @@
1
  === Resize Image After Upload ===
2
  Contributors: jepsonrae
3
- Donate link: http://www.jepsonrae.com/
4
  Tags: image, plugin, resize, upload
5
  Requires at least: 2.6
6
- Tested up to: 3.5.1
7
- Stable tag: 1.1.1
8
 
9
  This plugin resizes uploaded images to within a given maximum width and height after uploading, discarding the original uploaded file in the process.
10
 
11
  == Description ==
12
 
13
- This plugin resizes uploaded images to within a given maximum width and height after uploading, discarding the original uploaded file in the process. The original image is destroyed to save space, and unfortunately EXIF data is lost due to this process.
14
 
15
  The requirement for this plugin is due to the fact that digital cameras and mobile phones now take pictures of over 4000x3000 pixels in dimension, and can range in size from a few MB, to 20MB. Having these original images stored on the server can quickly consume up valuable disk space. This plugin will reduce the size of the uploaded image at point of upload; then either WordPress or some other resize script such as TimThumb can then further reduce the image size to suit positioning in the website theme.
16
 
@@ -31,6 +31,9 @@ The plugin uses a class originally from Jacob Wyke (www.redvodkajelly.com) and i
31
 
32
  == Changelog ==
33
 
 
 
 
34
  = 1.1.1 =
35
  * [Fix] Corrected functionality that sets default plugin options if the plugin version number changes.
36
  * [Fix] Adds default option for max-height value.
1
  === Resize Image After Upload ===
2
  Contributors: jepsonrae
3
+ Donate link: http://www.jepsonrae.com/?utm_campaign=plugins&utm_source=wp-resize-image-after-upload&utm_medium=donate-link
4
  Tags: image, plugin, resize, upload
5
  Requires at least: 2.6
6
+ Tested up to: 3.5.2
7
+ Stable tag: 1.2.0
8
 
9
  This plugin resizes uploaded images to within a given maximum width and height after uploading, discarding the original uploaded file in the process.
10
 
11
  == Description ==
12
 
13
+ This plugin resizes uploaded images to within a given maximum width and height after uploading, discarding the original uploaded file in the process. The original image is destroyed to save space, and unfortunately EXIF dataa is lost due to this process.
14
 
15
  The requirement for this plugin is due to the fact that digital cameras and mobile phones now take pictures of over 4000x3000 pixels in dimension, and can range in size from a few MB, to 20MB. Having these original images stored on the server can quickly consume up valuable disk space. This plugin will reduce the size of the uploaded image at point of upload; then either WordPress or some other resize script such as TimThumb can then further reduce the image size to suit positioning in the website theme.
16
 
31
 
32
  == Changelog ==
33
 
34
+ = 1.2.0 =
35
+ * [Update] Now only runs images through the resizer if required (i.e. the image is actually larger than the max height/width).
36
+
37
  = 1.1.1 =
38
  * [Fix] Corrected functionality that sets default plugin options if the plugin version number changes.
39
  * [Fix] Adds default option for max-height value.
resize-image-after-upload.php CHANGED
@@ -4,13 +4,13 @@ Plugin Name: Resize Image After Upload
4
  Plugin URI: http://www.jepsonrae.com/?utm_campaign=plugins&utm_source=wp-resize-image-after-upload&utm_medium=plugin-url
5
  Description: This plugin resizes uploaded images to a given width or height (whichever is the largest) after uploading, discarding the original uploaded file in the process.
6
  Author: Jepson Rae
7
- Version: 1.1.1
8
  Author URI: http://www.jepsonrae.com/?utm_campaign=plugins&utm_source=wp-resize-image-after-upload&utm_medium=author-url
9
 
10
 
11
 
12
  Copyright (C) 2008 A. Huizinga (original Resize at Upload plugin)
13
- Copyright (C) 2012 Jepson Rae Ltd
14
 
15
 
16
 
@@ -36,7 +36,7 @@ along with this program; if not, write to the Free Software
36
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37
  */
38
 
39
- $PLUGIN_VERSION = '1.1.1';
40
 
41
 
42
  // Set the default plugin values
@@ -151,23 +151,46 @@ function jr_uploadresize_options(){
151
 
152
 
153
 
154
- /* This function will apply changes to the uploaded file */
 
 
 
155
  function jr_uploadresize_resize($array){
156
- // $array contains file, url, type
157
- if ($array['type'] == 'image/jpeg' OR $array['type'] == 'image/gif' OR $array['type'] == 'image/png') {
158
- // there is a file to handle, so include the class and get the variables
 
 
 
 
 
 
159
  require_once('class.resize.php');
160
- $maxwidth = get_option('jr_resizeupload_width');
161
- $maxheight = get_option('jr_resizeupload_height');
162
- //$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'W', $maxwidth);
163
- $info=getimagesize($array['file']);
164
- if ($info[0]>$info[1]) {
165
- //Resize by width
166
- $objResize = new RVJ_ImageResize($array['file'], $array['file'], 'W', $maxwidth);
167
- } else {
168
- //Resize by height
169
- $objResize = new RVJ_ImageResize($array['file'], $array['file'], 'H', $maxheight);
170
- }
171
- } // if
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  return $array;
173
  } // function
4
  Plugin URI: http://www.jepsonrae.com/?utm_campaign=plugins&utm_source=wp-resize-image-after-upload&utm_medium=plugin-url
5
  Description: This plugin resizes uploaded images to a given width or height (whichever is the largest) after uploading, discarding the original uploaded file in the process.
6
  Author: Jepson Rae
7
+ Version: 1.2.0
8
  Author URI: http://www.jepsonrae.com/?utm_campaign=plugins&utm_source=wp-resize-image-after-upload&utm_medium=author-url
9
 
10
 
11
 
12
  Copyright (C) 2008 A. Huizinga (original Resize at Upload plugin)
13
+ Copyright (C) 2013 Jepson Rae Ltd
14
 
15
 
16
 
36
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37
  */
38
 
39
+ $PLUGIN_VERSION = '1.2.0';
40
 
41
 
42
  // Set the default plugin values
151
 
152
 
153
 
154
+ /**
155
+ * This function will apply changes to the uploaded file
156
+ * @param $array - contains file, url, type
157
+ */
158
  function jr_uploadresize_resize($array){
159
+
160
+ if(
161
+ $array['type'] == 'image/jpeg' ||
162
+ $array['type'] == 'image/gif' ||
163
+ $array['type'] == 'image/png')
164
+
165
+ {
166
+
167
+ // Include the file to carry out the resizing
168
  require_once('class.resize.php');
169
+
170
+ // Get resizing limits
171
+ $max_width = get_option('jr_resizeupload_width');
172
+ $max_height = get_option('jr_resizeupload_height');
173
+
174
+ // Get original image sizes
175
+ $original_info = getimagesize($array['file']);
176
+ $original_width = $original_info[0];
177
+ $original_height = $original_info[1];
178
+
179
+ // Perform the resize only if required, i.e. the image is larger than the max sizes
180
+ if($original_width > $max_width || $original_height > $max_height) {
181
+
182
+ //Resize by width
183
+ if($original_width > $original_height) {
184
+ $objResize = new RVJ_ImageResize($array['file'], $array['file'], 'W', $max_width);
185
+
186
+ }
187
+
188
+ //Resize by height
189
+ else {
190
+ $objResize = new RVJ_ImageResize($array['file'], $array['file'], 'H', $max_height);
191
+ }
192
+ }
193
+ }
194
+
195
  return $array;
196
  } // function