From 17074e5f70d3ce17a7b176b9a645a1ddb624687f Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Fri, 28 Aug 2015 12:28:34 -0400 Subject: [PATCH] SAAS-1032: Shows with missing show art on disk can't be edited --- .../application/services/ShowFormService.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 962a4de67..8b700cd3a 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -344,11 +344,21 @@ class Application_Service_ShowFormService * - the data URI representation of the image */ private function imagePathToDataUri($path) { - ob_start(); - header("Content-type: image/*"); - readfile($path); - $imageData = base64_encode(ob_get_contents()); - ob_end_clean(); + $imageData = null; + $bytesRead = 0; + try { + ob_start(); + header("Content-type: image/*"); + $bytesRead = @readfile($path); + $imageData = base64_encode(ob_get_contents()); + ob_end_clean(); + if ($bytesRead === FALSE) { + $imageData = null; + } + } catch (Exception $e) { + Logging::error("Failed to read image: " . $path); + $imageData = null; + } // return the data URI - data:{mime};base64,{data} return ($imageData === null || $imageData === '') ? '' : 'data: '.mime_content_type($path).';base64,'.$imageData;