From 82d3530777e3088f1771ddaaa12eafbd0cc92391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 18 Jul 2020 16:35:00 +0200 Subject: [PATCH] Corrupt Cover Art prohibits mp3 upload Don't throw an exception on corrupted cover art image data in upload. The order of processing needs to be the other way around. --- airtime_mvc/application/common/FileDataHelper.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/common/FileDataHelper.php b/airtime_mvc/application/common/FileDataHelper.php index 589a8c9eb..087e8609e 100644 --- a/airtime_mvc/application/common/FileDataHelper.php +++ b/airtime_mvc/application/common/FileDataHelper.php @@ -394,16 +394,18 @@ class FileDataHelper { $im = @imagecreatefromjpeg($get_cont); } - if ($size){ - $im = imagescale($im , $size); - } - - if(!$im) { + // if one of those bombs, create an error image instead + if (!$im) { $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); - imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc); + imagestring($im, 1, 5, 5, 'Error loading ' . $converted_filename, $tc); + } + + // scale if appropriate + if ($size){ + $im = imagescale($im , $size); } $img = $im;