@@ -279,6 +279,10 @@ protected function create_scaled_image($file_name, $version, $options) {
279
279
} else {
280
280
$ new_file_path = $ file_path ;
281
281
}
282
+ if (!function_exists ('getimagesize ' )) {
283
+ error_log ('Function not found: getimagesize ' );
284
+ return false ;
285
+ }
282
286
list ($ img_width , $ img_height ) = @getimagesize ($ file_path );
283
287
if (!$ img_width || !$ img_height ) {
284
288
return false ;
@@ -295,6 +299,11 @@ protected function create_scaled_image($file_name, $version, $options) {
295
299
}
296
300
return true ;
297
301
}
302
+
303
+ if (!function_exists ('imagecreatetruecolor ' )) {
304
+ error_log ('Function not found: imagecreatetruecolor ' );
305
+ return false ;
306
+ }
298
307
if (empty ($ options ['crop ' ])) {
299
308
$ new_width = $ img_width * $ scale ;
300
309
$ new_height = $ img_height * $ scale ;
@@ -569,6 +578,7 @@ protected function handle_file_upload($uploaded_file, $name, $size, $type, $erro
569
578
$ this ->orient_image ($ file_path );
570
579
}
571
580
$ file ->url = $ this ->get_download_url ($ file ->name );
581
+ $ failed_versions = array ();
572
582
foreach ($ this ->options ['image_versions ' ] as $ version => $ options ) {
573
583
if ($ this ->create_scaled_image ($ file ->name , $ version , $ options )) {
574
584
if (!empty ($ version )) {
@@ -579,8 +589,20 @@ protected function handle_file_upload($uploaded_file, $name, $size, $type, $erro
579
589
} else {
580
590
$ file_size = $ this ->get_file_size ($ file_path , true );
581
591
}
592
+ } else {
593
+ $ failed_versions [] = $ version ;
582
594
}
583
595
}
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
+ }
584
606
} else if (!$ content_range && $ this ->options ['discard_aborted_uploads ' ]) {
585
607
unlink ($ file_path );
586
608
$ file ->error = 'abort ' ;
0 commit comments