Skip to content

Commit e22f52c

Browse files
committed
Show error message if creation of scaled image version fails
1 parent a0d4edc commit e22f52c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

server/php/UploadHandler.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ protected function handle_file_upload($uploaded_file, $name, $size, $type, $erro
578578
$this->orient_image($file_path);
579579
}
580580
$file->url = $this->get_download_url($file->name);
581+
$failed_versions = array();
581582
foreach($this->options['image_versions'] as $version => $options) {
582583
if ($this->create_scaled_image($file->name, $version, $options)) {
583584
if (!empty($version)) {
@@ -588,8 +589,20 @@ protected function handle_file_upload($uploaded_file, $name, $size, $type, $erro
588589
} else {
589590
$file_size = $this->get_file_size($file_path, true);
590591
}
592+
} else {
593+
$failed_versions[] = $version;
591594
}
592595
}
596+
switch (count($failed_versions)) {
597+
case 0:
598+
break;
599+
case 1:
600+
$file->error = 'Failed to create scaled version: '.$failed_versions[0];
601+
break;
602+
default:
603+
$file->error = 'Failed to create scaled versions: '.implode($failed_versions,', ');
604+
break;
605+
}
593606
} else if (!$content_range && $this->options['discard_aborted_uploads']) {
594607
unlink($file_path);
595608
$file->error = 'abort';

0 commit comments

Comments
 (0)