Skip to content

Commit 1b56aee

Browse files
committed
Only create scaled image versions for inline file types.
1 parent a602c30 commit 1b56aee

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

server/php/UploadHandler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* jQuery File Upload Plugin PHP Class 6.6.1
3+
* jQuery File Upload Plugin PHP Class 6.6.2
44
* https://github.com/blueimp/jQuery-File-Upload
55
*
66
* Copyright 2010, Sebastian Tschan
@@ -353,9 +353,10 @@ protected function create_scaled_image($file_name, $version, $options) {
353353
$options['png_quality'] : 9;
354354
break;
355355
default:
356-
$src_img = null;
356+
imagedestroy($new_img);
357+
return false;
357358
}
358-
$success = $src_img && imagecopyresampled(
359+
$success = imagecopyresampled(
359360
$new_img,
360361
$src_img,
361362
$dst_x,
@@ -368,9 +369,7 @@ protected function create_scaled_image($file_name, $version, $options) {
368369
$img_height
369370
) && $write_image($new_img, $new_file_path, $image_quality);
370371
// Free up memory (imagedestroy does not delete files):
371-
if ($src_img) {
372-
imagedestroy($src_img);
373-
}
372+
imagedestroy($src_img);
374373
imagedestroy($new_img);
375374
return $success;
376375
}
@@ -692,7 +691,8 @@ protected function handle_file_upload($uploaded_file, $name, $size, $type, $erro
692691
if ($file_size === $file->size) {
693692
$file->url = $this->get_download_url($file->name);
694693
list($img_width, $img_height) = @getimagesize($file_path);
695-
if (is_int($img_width)) {
694+
if (is_int($img_width) &&
695+
preg_match($this->options['inline_file_types'], $file->name)) {
696696
$this->handle_image_file($file_path, $file);
697697
}
698698
} else {

0 commit comments

Comments
 (0)