Version Description
Fix a few edge case bugs, I go and break the main functionality - that's life! This is a maintenance release to fix a bug.
- [Fix] Correct the logic behind which direction to perform resizing in.
Download this release
Release Info
Developer | jepsonrae |
Plugin | Resize Image After Upload |
Version | 1.6.1 |
Comparing to | |
See all releases |
Code changes from version 1.6 to 1.6.1
- readme.txt +8 -1
- resize-image-after-upload.php +67 -53
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: image, processing, plugin, resize, upload, resizing, optimization, optimize, optimise, optimisation, downsize
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 4.0
|
7 |
-
Stable tag: 1.6
|
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 |
|
@@ -33,7 +33,14 @@ This plugin uses standard PHP image resizing functions and will require a high a
|
|
33 |
|
34 |
== Changelog ==
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
= 1.6 =
|
|
|
|
|
37 |
* [Update] Tidied up the plugin settings page.
|
38 |
* [Fix] Significant number of bug fixes through extensive testing.
|
39 |
* [Fix] Resizing wasn't running on square images.
|
4 |
Tags: image, processing, plugin, resize, upload, resizing, optimization, optimize, optimise, optimisation, downsize
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 4.0
|
7 |
+
Stable tag: 1.6.1
|
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 |
|
33 |
|
34 |
== Changelog ==
|
35 |
|
36 |
+
= 1.6.1 =
|
37 |
+
Fix a few edge case bugs, I go and break the main functionality - that's life! This is a maintenance release to fix a bug.
|
38 |
+
|
39 |
+
* [Fix] Correct the logic behind which direction to perform resizing in.
|
40 |
+
|
41 |
= 1.6 =
|
42 |
+
This is a major maintenance release to squash a few long outstanding bugs.
|
43 |
+
|
44 |
* [Update] Tidied up the plugin settings page.
|
45 |
* [Fix] Significant number of bug fixes through extensive testing.
|
46 |
* [Fix] Resizing wasn't running on square images.
|
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.6
|
8 |
Author URI: http://www.philr.ae/
|
9 |
|
10 |
Copyright (C) 2014 JEPSONRAE Ltd
|
@@ -30,7 +30,7 @@ along with this program; if not, write to the Free Software
|
|
30 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
31 |
*/
|
32 |
|
33 |
-
$PLUGIN_VERSION = '1.6';
|
34 |
$DEBUG_LOGGER = false;
|
35 |
|
36 |
|
@@ -349,6 +349,8 @@ function jr_uploadresize_options(){
|
|
349 |
*/
|
350 |
function jr_uploadresize_resize($image_data){
|
351 |
|
|
|
|
|
352 |
if(
|
353 |
$image_data['type'] == 'image/jpeg' ||
|
354 |
$image_data['type'] == 'image/jpg' ||
|
@@ -372,10 +374,10 @@ function jr_uploadresize_resize($image_data){
|
|
372 |
|
373 |
|
374 |
$max_width = get_option('jr_resizeupload_width')==0
|
375 |
-
?
|
376 |
|
377 |
$max_height = get_option('jr_resizeupload_height')==0
|
378 |
-
?
|
379 |
|
380 |
|
381 |
$convert_png_to_jpg = get_option('jr_resizeupload_convertpng_yesno');
|
@@ -412,64 +414,75 @@ function jr_uploadresize_resize($image_data){
|
|
412 |
}
|
413 |
|
414 |
|
415 |
-
if($DEBUG_LOGGER) error_log('LOG: '.print_r('
|
416 |
|
417 |
|
418 |
//
|
419 |
// Perform resizing operations if reduction is required
|
420 |
-
if(
|
421 |
-
|
422 |
-
&&
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
|
|
|
|
|
|
|
|
|
|
427 |
|
428 |
-
|
429 |
-
|
|
|
430 |
|
431 |
-
if($DEBUG_LOGGER) error_log('LOG: '.print_r('----square -by-width', true));
|
432 |
|
433 |
-
|
434 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
|
436 |
-
|
437 |
-
|
438 |
-
$resize_direction = 'H';
|
439 |
-
$resize_max = $max_height;
|
440 |
-
|
441 |
-
if($DEBUG_LOGGER) error_log('LOG: '.print_r('----square -by-height', true));
|
442 |
-
}
|
443 |
-
|
444 |
$objResize = new RVJ_ImageResize(
|
445 |
$image_data['file'], $image_data['file'],
|
446 |
$resize_direction, $resize_max,
|
447 |
$protect_image, $compression_level
|
448 |
);
|
|
|
|
|
|
|
449 |
}
|
450 |
-
|
451 |
-
|
452 |
-
// Resize by width1
|
453 |
-
else if($original_width > $original_height
|
454 |
-
&& $original_height <= $max_height) {
|
455 |
-
|
456 |
-
if($DEBUG_LOGGER) error_log('LOG: '.print_r('--by-width1', true));
|
457 |
-
$objResize = new RVJ_ImageResize($image_data['file'], $image_data['file'], 'W', $max_width, $protect_image, $compression_level);
|
458 |
-
}
|
459 |
-
|
460 |
-
// Resize by width2
|
461 |
-
else if($original_height > $original_width
|
462 |
-
&& $original_height <= $max_height) {
|
463 |
-
|
464 |
-
if($DEBUG_LOGGER) error_log('LOG: '.print_r('--by-width2', true));
|
465 |
-
$objResize = new RVJ_ImageResize($image_data['file'], $image_data['file'], 'W', $max_width, $protect_image, $compression_level);
|
466 |
-
}
|
467 |
-
|
468 |
-
// Resize by height
|
469 |
-
else {
|
470 |
-
if($DEBUG_LOGGER) error_log('LOG: '.print_r('--by-height', true));
|
471 |
-
$objResize = new RVJ_ImageResize($image_data['file'], $image_data['file'], 'H', $max_height, $protect_image, $compression_level);
|
472 |
-
}
|
473 |
}
|
474 |
|
475 |
|
@@ -480,20 +493,21 @@ if($DEBUG_LOGGER) error_log('LOG: '.print_r('--by-height', true));
|
|
480 |
|| ($original_is_gif && $convert_gif_to_jpg)
|
481 |
|| ($original_is_bmp && $convert_bmp_to_jpg)) {
|
482 |
|
483 |
-
|
484 |
-
|
485 |
-
$protext_image = false;
|
486 |
$objResize = new RVJ_ImageResize($image_data['file'], $image_data['file'], 'P', 100, $protect_image, $compression_level);
|
|
|
|
|
487 |
}
|
488 |
|
489 |
|
490 |
//
|
491 |
// No resizing, recompression, or conversion required
|
492 |
else {
|
493 |
-
if($DEBUG_LOGGER) error_log('LOG: '.print_r('--no-action-required', true));
|
494 |
}
|
495 |
|
496 |
-
if($DEBUG_LOGGER) error_log('LOG: '.print_r(
|
497 |
|
498 |
} // if(...)
|
499 |
|
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.6.1
|
8 |
Author URI: http://www.philr.ae/
|
9 |
|
10 |
Copyright (C) 2014 JEPSONRAE Ltd
|
30 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
31 |
*/
|
32 |
|
33 |
+
$PLUGIN_VERSION = '1.6.1';
|
34 |
$DEBUG_LOGGER = false;
|
35 |
|
36 |
|
349 |
*/
|
350 |
function jr_uploadresize_resize($image_data){
|
351 |
|
352 |
+
global $DEBUG_LOGGER;
|
353 |
+
|
354 |
if(
|
355 |
$image_data['type'] == 'image/jpeg' ||
|
356 |
$image_data['type'] == 'image/jpg' ||
|
374 |
|
375 |
|
376 |
$max_width = get_option('jr_resizeupload_width')==0
|
377 |
+
? false : get_option('jr_resizeupload_width');
|
378 |
|
379 |
$max_height = get_option('jr_resizeupload_height')==0
|
380 |
+
? false : get_option('jr_resizeupload_height');
|
381 |
|
382 |
|
383 |
$convert_png_to_jpg = get_option('jr_resizeupload_convertpng_yesno');
|
414 |
}
|
415 |
|
416 |
|
417 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r('upload-start', true));
|
418 |
|
419 |
|
420 |
//
|
421 |
// Perform resizing operations if reduction is required
|
422 |
+
if(
|
423 |
+
$resizing_enabled
|
424 |
+
&& ($max_width || $max_height) // resize in at least one dimension
|
425 |
+
&& (
|
426 |
+
($max_width && ($original_width > $max_width)) // width possibly needs resizing
|
427 |
+
||
|
428 |
+
($max_height && ($original_height > $max_height)) // height possibly needs resizing
|
429 |
+
)
|
430 |
+
&& !$original_is_bmp) // plugin does not work with bitmaps
|
431 |
+
{
|
432 |
+
|
433 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r('--resizing', true));
|
434 |
|
435 |
+
$protect_image = true;
|
436 |
+
$resize_direction = null;
|
437 |
+
$resize_max = null;
|
438 |
|
|
|
439 |
|
440 |
+
// Width is unlimited, limit by height
|
441 |
+
if((!$max_width && $max_height)
|
442 |
+
&& ($original_height > $max_height)) {
|
443 |
+
|
444 |
+
$resize_direction = 'H';
|
445 |
+
$resize_max = $max_height;
|
446 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r(' >--by-height (width-unlimited)', true));
|
447 |
+
}
|
448 |
+
|
449 |
+
// Height is unlimited, limit by width
|
450 |
+
else if((!$max_height && $max_width)
|
451 |
+
&& ($original_width > $max_width)) {
|
452 |
+
|
453 |
+
$resize_direction = 'W';
|
454 |
+
$resize_max = $max_width;
|
455 |
+
|
456 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r(' >--by-width (height-unlimited)', true));
|
457 |
+
}
|
458 |
+
|
459 |
+
// Both dimensions require limiting, figure out which
|
460 |
+
else {
|
461 |
+
|
462 |
+
if(($original_height/$max_height) > ($original_width/$max_width)) {
|
463 |
+
$resize_direction = 'H';
|
464 |
+
$resize_max = $max_height;
|
465 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r(' >--by-height', true));
|
466 |
+
}
|
467 |
+
|
468 |
+
else {
|
469 |
+
$resize_direction = 'W';
|
470 |
+
$resize_max = $max_width;
|
471 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r(' >--by-width', true));
|
472 |
+
}
|
473 |
+
}
|
474 |
|
475 |
+
if(!is_null($resize_direction) && !is_null($resize_max)) {
|
476 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
477 |
$objResize = new RVJ_ImageResize(
|
478 |
$image_data['file'], $image_data['file'],
|
479 |
$resize_direction, $resize_max,
|
480 |
$protect_image, $compression_level
|
481 |
);
|
482 |
+
|
483 |
+
|
484 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r(' >--resize-done', true));
|
485 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
}
|
487 |
|
488 |
|
493 |
|| ($original_is_gif && $convert_gif_to_jpg)
|
494 |
|| ($original_is_bmp && $convert_bmp_to_jpg)) {
|
495 |
|
496 |
+
$protect_image = false;
|
497 |
+
|
|
|
498 |
$objResize = new RVJ_ImageResize($image_data['file'], $image_data['file'], 'P', 100, $protect_image, $compression_level);
|
499 |
+
|
500 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r('--recompression/conversion', true));
|
501 |
}
|
502 |
|
503 |
|
504 |
//
|
505 |
// No resizing, recompression, or conversion required
|
506 |
else {
|
507 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r('--no-action-required', true));
|
508 |
}
|
509 |
|
510 |
+
if($DEBUG_LOGGER) error_log('LOG: '.print_r("end\n", true));
|
511 |
|
512 |
} // if(...)
|
513 |
|