Version Description
- [update] Added ability to set the JPEG compression quality level when JPEGs are resized. Default is 90.
Download this release
Release Info
| Developer | jepsonrae |
| Plugin | |
| Version | 1.3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.2.0 to 1.3.0
- class.resize.php +12 -7
- readme.txt +5 -2
- resize-image-after-upload.php +124 -81
- screenshot-1.jpg +0 -0
class.resize.php
CHANGED
|
@@ -64,6 +64,7 @@ class RVJ_ImageResize {
|
|
| 64 |
var $arrResizedDetails;
|
| 65 |
var $resOriginalImage;
|
| 66 |
var $resResizedImage;
|
|
|
|
| 67 |
var $boolProtect = true;
|
| 68 |
|
| 69 |
/*
|
|
@@ -75,11 +76,12 @@ class RVJ_ImageResize {
|
|
| 75 |
* @Param-3: strType - String - The type of resize you want to perform
|
| 76 |
* @Param-4: value - Number/Array - The resize dimensions
|
| 77 |
* @Param-5: boolProect - Boolen - Protects the image so that it doesnt resize an image if its already smaller
|
|
|
|
| 78 |
* @Description: Calls the RVJ_Pagination method so its php 4 compatible
|
| 79 |
*
|
| 80 |
*/
|
| 81 |
|
| 82 |
-
function __constructor($strPath, $strSavePath, $strType = "W", $value = "150", $boolProtect = true){
|
| 83 |
$this->RVJ_ImageResize($strPath, $strSavePath, $strType, $value);
|
| 84 |
}
|
| 85 |
|
|
@@ -91,15 +93,17 @@ class RVJ_ImageResize {
|
|
| 91 |
* @Param-2: strSavePath - String - The path to save the new image to
|
| 92 |
* @Param-3: strType - String - The type of resize you want to perform
|
| 93 |
* @Param-4: value - Number/Array - The resize dimensions
|
| 94 |
-
* @Param-5: boolProect - Boolen - Protects the image so that it doesnt resize an image if its already smaller
|
|
|
|
| 95 |
* @Description: Calls the RVJ_Pagination method so its php 4 compatible
|
| 96 |
*
|
| 97 |
*/
|
| 98 |
|
| 99 |
-
function RVJ_ImageResize($strPath, $strSavePath, $strType = "W", $value = "150", $boolProtect = true){
|
| 100 |
//save the image/path details
|
| 101 |
$this->strOriginalImagePath = $strPath;
|
| 102 |
$this->strResizedImagePath = $strSavePath;
|
|
|
|
| 103 |
$this->boolProtect = $boolProtect;
|
| 104 |
|
| 105 |
//get the image dimensions
|
|
@@ -206,7 +210,7 @@ class RVJ_ImageResize {
|
|
| 206 |
imagepng($this->resResizedImage, $this->strResizedImagePath, 7);
|
| 207 |
break;
|
| 208 |
case "image/gif":
|
| 209 |
-
imagegif($this->resResizedImage, $this->strResizedImagePath
|
| 210 |
break;
|
| 211 |
}
|
| 212 |
}
|
|
@@ -258,11 +262,12 @@ class RVJ_ImageResize {
|
|
| 258 |
* @Parameters: 2
|
| 259 |
* @Param-1: numWidth - Number - The width of the image in pixels
|
| 260 |
* @Param-2: numHeight - Number - The height of the image in pixes
|
|
|
|
| 261 |
* @Description: Resizes the image by creatin a new canvas and copying the image over onto it. DONT CALL THIS METHOD DIRECTLY - USE THE METHODS BELOW
|
| 262 |
*
|
| 263 |
*/
|
| 264 |
|
| 265 |
-
function _resize($numWidth, $numHeight){
|
| 266 |
//check for image protection
|
| 267 |
if($this->_imageProtect($numWidth, $numHeight)){
|
| 268 |
if($this->arrOriginalDetails['mime']=="image/gif"){
|
|
@@ -287,7 +292,7 @@ class RVJ_ImageResize {
|
|
| 287 |
imagecopyresized($this->resResizedImage, $this->resOriginalImage, 0, 0, 0, 0, $numWidth, $numHeight, $this->arrOriginalDetails[0], $this->arrOriginalDetails[1]);
|
| 288 |
}
|
| 289 |
//saves the image
|
| 290 |
-
$this->saveImage();
|
| 291 |
}
|
| 292 |
}
|
| 293 |
|
|
@@ -319,7 +324,7 @@ class RVJ_ImageResize {
|
|
| 319 |
|
| 320 |
function resizeToWidth($numWidth){
|
| 321 |
$numHeight=(int)(($numWidth*$this->arrOriginalDetails[1])/$this->arrOriginalDetails[0]);
|
| 322 |
-
$this->_resize($numWidth, $numHeight);
|
| 323 |
}
|
| 324 |
|
| 325 |
/*
|
| 64 |
var $arrResizedDetails;
|
| 65 |
var $resOriginalImage;
|
| 66 |
var $resResizedImage;
|
| 67 |
+
var $numQuality = 95;
|
| 68 |
var $boolProtect = true;
|
| 69 |
|
| 70 |
/*
|
| 76 |
* @Param-3: strType - String - The type of resize you want to perform
|
| 77 |
* @Param-4: value - Number/Array - The resize dimensions
|
| 78 |
* @Param-5: boolProect - Boolen - Protects the image so that it doesnt resize an image if its already smaller
|
| 79 |
+
* @Param-6: numQuality - Number - The quality of compression if output is a JPEG
|
| 80 |
* @Description: Calls the RVJ_Pagination method so its php 4 compatible
|
| 81 |
*
|
| 82 |
*/
|
| 83 |
|
| 84 |
+
function __constructor($strPath, $strSavePath, $strType = "W", $value = "150", $boolProtect = true, $numQuality = 95){
|
| 85 |
$this->RVJ_ImageResize($strPath, $strSavePath, $strType, $value);
|
| 86 |
}
|
| 87 |
|
| 93 |
* @Param-2: strSavePath - String - The path to save the new image to
|
| 94 |
* @Param-3: strType - String - The type of resize you want to perform
|
| 95 |
* @Param-4: value - Number/Array - The resize dimensions
|
| 96 |
+
* @Param-5: boolProect - Boolen - Protects the image so that it doesnt resize an image if its already smaller
|
| 97 |
+
* @Param-6: numQuality - Number - The quality of compression if output is a JPEG
|
| 98 |
* @Description: Calls the RVJ_Pagination method so its php 4 compatible
|
| 99 |
*
|
| 100 |
*/
|
| 101 |
|
| 102 |
+
function RVJ_ImageResize($strPath, $strSavePath, $strType = "W", $value = "150", $boolProtect = true, $numQuality = 95){
|
| 103 |
//save the image/path details
|
| 104 |
$this->strOriginalImagePath = $strPath;
|
| 105 |
$this->strResizedImagePath = $strSavePath;
|
| 106 |
+
$this->numQuality = $numQuality;
|
| 107 |
$this->boolProtect = $boolProtect;
|
| 108 |
|
| 109 |
//get the image dimensions
|
| 210 |
imagepng($this->resResizedImage, $this->strResizedImagePath, 7);
|
| 211 |
break;
|
| 212 |
case "image/gif":
|
| 213 |
+
imagegif($this->resResizedImage, $this->strResizedImagePath);
|
| 214 |
break;
|
| 215 |
}
|
| 216 |
}
|
| 262 |
* @Parameters: 2
|
| 263 |
* @Param-1: numWidth - Number - The width of the image in pixels
|
| 264 |
* @Param-2: numHeight - Number - The height of the image in pixes
|
| 265 |
+
* @Param-3: numQuality - Number - The quality of compression if output is a JPEG
|
| 266 |
* @Description: Resizes the image by creatin a new canvas and copying the image over onto it. DONT CALL THIS METHOD DIRECTLY - USE THE METHODS BELOW
|
| 267 |
*
|
| 268 |
*/
|
| 269 |
|
| 270 |
+
function _resize($numWidth, $numHeight, $numQuality=95){
|
| 271 |
//check for image protection
|
| 272 |
if($this->_imageProtect($numWidth, $numHeight)){
|
| 273 |
if($this->arrOriginalDetails['mime']=="image/gif"){
|
| 292 |
imagecopyresized($this->resResizedImage, $this->resOriginalImage, 0, 0, 0, 0, $numWidth, $numHeight, $this->arrOriginalDetails[0], $this->arrOriginalDetails[1]);
|
| 293 |
}
|
| 294 |
//saves the image
|
| 295 |
+
$this->saveImage($numQuality);
|
| 296 |
}
|
| 297 |
}
|
| 298 |
|
| 324 |
|
| 325 |
function resizeToWidth($numWidth){
|
| 326 |
$numHeight=(int)(($numWidth*$this->arrOriginalDetails[1])/$this->arrOriginalDetails[0]);
|
| 327 |
+
$this->_resize($numWidth, $numHeight, $this->numQuality);
|
| 328 |
}
|
| 329 |
|
| 330 |
/*
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: http://www.jepsonrae.com/?utm_campaign=plugins&utm_source=wp-resize
|
|
| 4 |
Tags: image, plugin, resize, upload
|
| 5 |
Requires at least: 2.6
|
| 6 |
Tested up to: 3.5.2
|
| 7 |
-
Stable tag: 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 |
|
|
@@ -30,9 +30,12 @@ The plugin uses a class originally from Jacob Wyke (www.redvodkajelly.com) and i
|
|
| 30 |
1. Full preview of the settings screen
|
| 31 |
|
| 32 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
= 1.2.0 =
|
| 35 |
-
* [Update] Now only runs images through the resizer if required
|
| 36 |
|
| 37 |
= 1.1.1 =
|
| 38 |
* [Fix] Corrected functionality that sets default plugin options if the plugin version number changes.
|
| 4 |
Tags: image, plugin, resize, upload
|
| 5 |
Requires at least: 2.6
|
| 6 |
Tested up to: 3.5.2
|
| 7 |
+
Stable tag: 1.3.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 |
|
| 30 |
1. Full preview of the settings screen
|
| 31 |
|
| 32 |
== Changelog ==
|
| 33 |
+
|
| 34 |
+
= 1.3.0 =
|
| 35 |
+
* [update] Added ability to set the JPEG compression quality level when JPEGs are resized. Default is 90.
|
| 36 |
|
| 37 |
= 1.2.0 =
|
| 38 |
+
* [Update] Now only runs images through the resizer if required, i.e. the image is actually larger than the max height/width.
|
| 39 |
|
| 40 |
= 1.1.1 =
|
| 41 |
* [Fix] Corrected functionality that sets default plugin options if the plugin version number changes.
|
resize-image-after-upload.php
CHANGED
|
@@ -4,7 +4,7 @@ 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.
|
| 8 |
Author URI: http://www.jepsonrae.com/?utm_campaign=plugins&utm_source=wp-resize-image-after-upload&utm_medium=author-url
|
| 9 |
|
| 10 |
|
|
@@ -16,8 +16,8 @@ Copyright (C) 2013 Jepson Rae Ltd
|
|
| 16 |
|
| 17 |
Includes hints and code by:
|
| 18 |
Huiz.net (www.huiz.net)
|
| 19 |
-
|
| 20 |
-
|
| 21 |
|
| 22 |
|
| 23 |
|
|
@@ -36,52 +36,87 @@ 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.
|
| 40 |
|
| 41 |
|
| 42 |
-
//
|
| 43 |
if(get_option('jr_resizeupload_version') != $PLUGIN_VERSION) {
|
| 44 |
|
| 45 |
-
add_option('jr_resizeupload_version',
|
| 46 |
-
add_option('jr_resizeupload_width',
|
| 47 |
-
add_option('jr_resizeupload_height','1200', '', 'yes');
|
| 48 |
-
add_option('
|
| 49 |
-
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
| 54 |
if (get_option('jr_resizeupload_resize_yesno') == 'yes') {
|
| 55 |
-
|
| 56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
function jr_uploadresize_options_page(){
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
| 68 |
function jr_uploadresize_options(){
|
| 69 |
|
| 70 |
if (isset($_POST['jr_options_update'])) {
|
|
|
|
| 71 |
$maxwidth = trim(mysql_real_escape_string($_POST['maxwidth']));
|
| 72 |
$maxheight = trim(mysql_real_escape_string($_POST['maxheight']));
|
|
|
|
| 73 |
$yesno = $_POST['yesno'];
|
| 74 |
|
| 75 |
// if input is empty or not an integer, use previous setting
|
| 76 |
-
if ($maxwidth == ''
|
| 77 |
-
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
update_option('jr_resizeupload_width',$maxwidth);
|
| 84 |
update_option('jr_resizeupload_height',$maxheight);
|
|
|
|
| 85 |
|
| 86 |
if ($yesno == 'yes') {
|
| 87 |
update_option('jr_resizeupload_resize_yesno','yes');
|
|
@@ -98,56 +133,63 @@ function jr_uploadresize_options(){
|
|
| 98 |
// get options and show settings form
|
| 99 |
$maxwidth = get_option('jr_resizeupload_width');
|
| 100 |
$maxheight = get_option('jr_resizeupload_height');
|
|
|
|
| 101 |
$yesno = get_option('jr_resizeupload_resize_yesno');
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
|
| 153 |
|
|
@@ -160,8 +202,7 @@ function jr_uploadresize_resize($array){
|
|
| 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
|
|
@@ -170,6 +211,8 @@ function jr_uploadresize_resize($array){
|
|
| 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']);
|
|
@@ -181,16 +224,16 @@ function jr_uploadresize_resize($array){
|
|
| 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
|
| 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.3.0
|
| 8 |
Author URI: http://www.jepsonrae.com/?utm_campaign=plugins&utm_source=wp-resize-image-after-upload&utm_medium=author-url
|
| 9 |
|
| 10 |
|
| 16 |
|
| 17 |
Includes hints and code by:
|
| 18 |
Huiz.net (www.huiz.net)
|
| 19 |
+
Jacob Wyke (www.redvodkajelly.com)
|
| 20 |
+
Paolo Tresso / Pixline (http://pixline.net)
|
| 21 |
|
| 22 |
|
| 23 |
|
| 36 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| 37 |
*/
|
| 38 |
|
| 39 |
+
$PLUGIN_VERSION = '1.3.0';
|
| 40 |
|
| 41 |
|
| 42 |
+
// Default plugin values
|
| 43 |
if(get_option('jr_resizeupload_version') != $PLUGIN_VERSION) {
|
| 44 |
|
| 45 |
+
add_option('jr_resizeupload_version', $PLUGIN_VERSION, '','yes');
|
| 46 |
+
add_option('jr_resizeupload_width', '1200', '', 'yes');
|
| 47 |
+
add_option('jr_resizeupload_height', '1200', '', 'yes');
|
| 48 |
+
add_option('jr_resizeupload_quality', '90', '', 'yes');
|
| 49 |
+
add_option('jr_resizeupload_resize_yesno', 'yes', '','yes');
|
| 50 |
+
}
|
| 51 |
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
// Hook in the options page
|
| 55 |
+
add_action('admin_menu', 'jr_uploadresize_options_page');
|
| 56 |
+
|
| 57 |
+
// Hook the function to the upload handler
|
| 58 |
if (get_option('jr_resizeupload_resize_yesno') == 'yes') {
|
| 59 |
+
add_action('wp_handle_upload', 'jr_uploadresize_resize'); // apply our modifications
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
|
| 66 |
|
| 67 |
+
/**
|
| 68 |
+
* Add the options page
|
| 69 |
+
*/
|
| 70 |
function jr_uploadresize_options_page(){
|
| 71 |
+
if(function_exists('add_options_page')){
|
| 72 |
+
add_options_page(
|
| 73 |
+
'Resize Image After Upload',
|
| 74 |
+
'Resize Image Upload',
|
| 75 |
+
'manage_options',
|
| 76 |
+
'resize-after-upload',
|
| 77 |
+
'jr_uploadresize_options'
|
| 78 |
+
);
|
| 79 |
+
}
|
| 80 |
+
} // function jr_uploadresize_options_page(){
|
| 81 |
|
| 82 |
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Define the Options page for the plugin
|
| 86 |
+
*/
|
| 87 |
function jr_uploadresize_options(){
|
| 88 |
|
| 89 |
if (isset($_POST['jr_options_update'])) {
|
| 90 |
+
|
| 91 |
$maxwidth = trim(mysql_real_escape_string($_POST['maxwidth']));
|
| 92 |
$maxheight = trim(mysql_real_escape_string($_POST['maxheight']));
|
| 93 |
+
$quality = trim(mysql_real_escape_string($_POST['quality']));
|
| 94 |
$yesno = $_POST['yesno'];
|
| 95 |
|
| 96 |
// if input is empty or not an integer, use previous setting
|
| 97 |
+
if ($maxwidth == '' || ctype_digit(strval($maxwidth)) == FALSE) {
|
| 98 |
+
$maxwidth = get_option('jr_resizeupload_width');
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
if ($maxheight == '' || ctype_digit(strval($maxheight)) == FALSE) {
|
| 102 |
+
$maxheight = get_option('jr_resizeupload_height');
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
if ($quality == '' || ctype_digit(strval($quality)) == FALSE) {
|
| 106 |
+
$quality = get_option('jr_resizeupload_quality');
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
if($quality<0) {
|
| 110 |
+
$quality=0;
|
| 111 |
+
}
|
| 112 |
+
else if($quality>100) {
|
| 113 |
+
$quality=100;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
|
| 117 |
update_option('jr_resizeupload_width',$maxwidth);
|
| 118 |
update_option('jr_resizeupload_height',$maxheight);
|
| 119 |
+
update_option('jr_resizeupload_quality',$quality);
|
| 120 |
|
| 121 |
if ($yesno == 'yes') {
|
| 122 |
update_option('jr_resizeupload_resize_yesno','yes');
|
| 133 |
// get options and show settings form
|
| 134 |
$maxwidth = get_option('jr_resizeupload_width');
|
| 135 |
$maxheight = get_option('jr_resizeupload_height');
|
| 136 |
+
$quality = get_option('jr_resizeupload_quality');
|
| 137 |
$yesno = get_option('jr_resizeupload_resize_yesno');
|
| 138 |
+
?>
|
| 139 |
+
|
| 140 |
+
<div class="wrap">
|
| 141 |
+
<form method="post" accept-charset="utf-8">
|
| 142 |
+
|
| 143 |
+
<h2>Resize Image After Upload Options</h2>
|
| 144 |
+
<p>This plugin resizes uploaded images to given maximum width and/or height after uploading, discarding the original uploaded file in the process.
|
| 145 |
+
You can set the max width and max height, and images (JPEG, PNG or GIF) will be resized automatically after they are uploaded.</p>
|
| 146 |
+
|
| 147 |
+
<p>Your file will be resized, there will not be a copy or backup with the original size.</p>
|
| 148 |
+
|
| 149 |
+
<p>Set the option 'Resize' to no if you want to disable resizing, this way you shouldn’t need to deactivate the plugin if you don’t want to resize for a while.</p>
|
| 150 |
+
|
| 151 |
+
<h3 style="margin-top:20px;border-top:1px solid #eee;padding-top:20px;">Settings</h3>
|
| 152 |
+
<table class="form-table">
|
| 153 |
+
<tr>
|
| 154 |
+
<td valign="top">Resize images: </td>
|
| 155 |
+
<td valign="top">
|
| 156 |
+
<select name="yesno" id="yesno">
|
| 157 |
+
<option value="no" label="no" <?php echo ($yesno == 'no') ? 'selected="selected"' : ''; ?>>No</option>
|
| 158 |
+
<option value="yes" label="yes" <?php echo ($yesno == 'yes') ? 'selected="selected"' : ''; ?>>Yes</option>
|
| 159 |
+
</select>
|
| 160 |
+
</td>
|
| 161 |
+
</tr>
|
| 162 |
+
|
| 163 |
+
<tr>
|
| 164 |
+
<td valign="top">Maximum width and height (pixels): </td>
|
| 165 |
+
<td valign="top">
|
| 166 |
+
<input type="text" name="maxwidth" size="7" id="maxwidth" value="<?php echo $maxwidth; ?>" /> px-wide
|
| 167 |
+
<br /><input type="text" name="maxheight" size="7" id="maxheight" value="<?php echo $maxheight; ?>" /> px-high
|
| 168 |
+
<br /><small>Integer pixel value (e.g. 1200)</small>
|
| 169 |
+
<br /><small>Recommended value: 1200</small>
|
| 170 |
+
</td>
|
| 171 |
+
</tr>
|
| 172 |
+
|
| 173 |
+
<tr>
|
| 174 |
+
<td valign="top">Compression quality (for JPEGs): </td>
|
| 175 |
+
<td valign="top">
|
| 176 |
+
<input type="text" name="quality" size="5" id="maxwidth" value="<?php echo $quality; ?>" />
|
| 177 |
+
<br /><small>Integer between 0 (low quality, smallest files) and 100 (best quality, largest files)</small>
|
| 178 |
+
<br /><small>Recommended value: 90</small>
|
| 179 |
+
</td>
|
| 180 |
+
</tr>
|
| 181 |
+
|
| 182 |
+
</table>
|
| 183 |
+
|
| 184 |
+
<p class="submit" style="margin-top:20px;border-top:1px solid #eee;padding-top:20px;">
|
| 185 |
+
<input type="hidden" name="action" value="update" />
|
| 186 |
+
<input id="submit" name="jr_options_update" class="button button-primary" type="submit" value="Update Options">
|
| 187 |
+
</p>
|
| 188 |
+
</form>
|
| 189 |
+
|
| 190 |
+
</div>
|
| 191 |
+
<?php
|
| 192 |
+
} // function jr_uploadresize_options(){
|
| 193 |
|
| 194 |
|
| 195 |
|
| 202 |
if(
|
| 203 |
$array['type'] == 'image/jpeg' ||
|
| 204 |
$array['type'] == 'image/gif' ||
|
| 205 |
+
$array['type'] == 'image/png')
|
|
|
|
| 206 |
{
|
| 207 |
|
| 208 |
// Include the file to carry out the resizing
|
| 211 |
// Get resizing limits
|
| 212 |
$max_width = get_option('jr_resizeupload_width');
|
| 213 |
$max_height = get_option('jr_resizeupload_height');
|
| 214 |
+
|
| 215 |
+
$quality = get_option('jr_resizeupload_quality');
|
| 216 |
|
| 217 |
// Get original image sizes
|
| 218 |
$original_info = getimagesize($array['file']);
|
| 224 |
|
| 225 |
//Resize by width
|
| 226 |
if($original_width > $original_height) {
|
| 227 |
+
$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'W', $max_width, true, $quality);
|
| 228 |
|
| 229 |
}
|
| 230 |
|
| 231 |
//Resize by height
|
| 232 |
else {
|
| 233 |
+
$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'H', $max_height, true, $quality);
|
| 234 |
}
|
| 235 |
}
|
| 236 |
}
|
| 237 |
|
| 238 |
return $array;
|
| 239 |
+
} // function jr_uploadresize_resize($array){
|
screenshot-1.jpg
CHANGED
|
Binary file
|
