Bump fileuploader to v9.32
This commit is contained in:
@@ -84,9 +84,9 @@ class UploadHandler
|
||||
const IMAGETYPE_PNG = 3;
|
||||
|
||||
protected $image_objects = array();
|
||||
protected $response = array();
|
||||
|
||||
public function __construct($options = null, $initialize = true, $error_messages = null) {
|
||||
$this->response = array();
|
||||
$this->options = array(
|
||||
'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')),
|
||||
'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',
|
||||
@@ -418,7 +418,11 @@ class UploadHandler
|
||||
public function get_config_bytes($val) {
|
||||
$val = trim($val);
|
||||
$last = strtolower($val[strlen($val)-1]);
|
||||
$val = (int)$val;
|
||||
if (is_numeric($val)) {
|
||||
$val = (int)$val;
|
||||
} else {
|
||||
$val = (int)substr($val, 0, -1);
|
||||
}
|
||||
switch ($last) {
|
||||
case 'g':
|
||||
$val *= 1024;
|
||||
@@ -492,7 +496,7 @@ class UploadHandler
|
||||
unset($tmp);
|
||||
}
|
||||
}
|
||||
if (!empty($img_width)) {
|
||||
if (!empty($img_width) && !empty($img_height)) {
|
||||
if ($max_width && $img_width > $max_width) {
|
||||
$file->error = $this->get_error_message('max_width');
|
||||
return false;
|
||||
@@ -836,9 +840,10 @@ class UploadHandler
|
||||
// Handle transparency in GIF and PNG images:
|
||||
switch ($type) {
|
||||
case 'gif':
|
||||
imagecolortransparent($new_img, imagecolorallocate($new_img, 0, 0, 0));
|
||||
break;
|
||||
case 'png':
|
||||
imagecolortransparent($new_img, imagecolorallocate($new_img, 0, 0, 0));
|
||||
case 'png':
|
||||
imagealphablending($new_img, false);
|
||||
imagesavealpha($new_img, true);
|
||||
break;
|
||||
@@ -868,7 +873,12 @@ class UploadHandler
|
||||
$image->setResourceLimit($type, $limit);
|
||||
}
|
||||
}
|
||||
$image->readImage($file_path);
|
||||
try {
|
||||
$image->readImage($file_path);
|
||||
} catch (ImagickException $e) {
|
||||
error_log($e->getMessage());
|
||||
return null;
|
||||
}
|
||||
$this->image_objects[$file_path] = $image;
|
||||
}
|
||||
return $this->image_objects[$file_path];
|
||||
@@ -925,6 +935,7 @@ class UploadHandler
|
||||
$file_path,
|
||||
!empty($options['crop']) || !empty($options['no_cache'])
|
||||
);
|
||||
if (is_null($image)) return false;
|
||||
if ($image->getImageFormat() === 'GIF') {
|
||||
// Handle animated GIFs:
|
||||
$images = $image->coalesceImages();
|
||||
@@ -938,11 +949,9 @@ class UploadHandler
|
||||
if (!empty($options['auto_orient'])) {
|
||||
$image_oriented = $this->imagick_orient_image($image);
|
||||
}
|
||||
|
||||
$image_resize = false;
|
||||
$new_width = $max_width = $img_width = $image->getImageWidth();
|
||||
$new_height = $max_height = $img_height = $image->getImageHeight();
|
||||
|
||||
// use isset(). User might be setting max_width = 0 (auto in regular resizing). Value 0 would be considered empty when you use empty()
|
||||
if (isset($options['max_width'])) {
|
||||
$image_resize = true;
|
||||
@@ -952,9 +961,7 @@ class UploadHandler
|
||||
$image_resize = true;
|
||||
$new_height = $max_height = $options['max_height'];
|
||||
}
|
||||
|
||||
$image_strip = (isset($options['strip']) ? $options['strip'] : false);
|
||||
|
||||
if ( !$image_oriented && ($max_width >= $img_width) && ($max_height >= $img_height) && !$image_strip && empty($options["jpeg_quality"]) ) {
|
||||
if ($file_path !== $new_file_path) {
|
||||
return copy($file_path, $new_file_path);
|
||||
@@ -1360,8 +1367,7 @@ class UploadHandler
|
||||
$json = json_encode($content);
|
||||
$redirect = stripslashes($this->get_post_param('redirect'));
|
||||
if ($redirect && preg_match($this->options['redirect_allow_target'], $redirect)) {
|
||||
$this->header('Location: '.sprintf($redirect, rawurlencode($json)));
|
||||
return;
|
||||
return $this->header('Location: '.sprintf($redirect, rawurlencode($json)));
|
||||
}
|
||||
$this->head();
|
||||
if ($this->get_server_var('HTTP_CONTENT_RANGE')) {
|
||||
|
||||
Reference in New Issue
Block a user