From 88f90f33b9fde55e987877e0235d1cf71523e631 Mon Sep 17 00:00:00 2001 From: Codenift Date: Sun, 13 Oct 2019 13:07:06 -0400 Subject: [PATCH] If id3 library is not present show default image Checks for getid3 library. Prevents site from failing. No images are fetched from audio files and will just show default image instead with a message on log saying to run install. --- .../application/common/FileDataHelper.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/common/FileDataHelper.php b/airtime_mvc/application/common/FileDataHelper.php index 3a8ccdef6..ba43ca107 100644 --- a/airtime_mvc/application/common/FileDataHelper.php +++ b/airtime_mvc/application/common/FileDataHelper.php @@ -113,8 +113,13 @@ class FileDataHelper { */ public static function saveArtworkData($analyzeFile, $filename, $importDir = null, $DbPath = null) { - $getID3 = new \getID3(); - $getFileInfo = $getID3->analyze($analyzeFile); + if (class_exists('getID3')) { + $getID3 = new \getID3(); + $getFileInfo = $getID3->analyze($analyzeFile); + } else { + $getFileInfo = []; + Logging::error("Failed to load getid3 library. Please run either 'composer install' or the 'install' script."); + } if(isset($getFileInfo['comments']['picture'][0])) { @@ -188,8 +193,13 @@ class FileDataHelper { $dbAudioPath = $md["MDATA_KEY_FILEPATH"]; $fullpath = $fp . $dbAudioPath; - $getID3 = new \getID3(); - $getFileInfo = $getID3->analyze($fullpath); + if (class_exists('getID3')) { + $getID3 = new \getID3(); + $getFileInfo = $getID3->analyze($fullpath); + } else { + $getFileInfo = []; + Logging::error("Failed to load getid3 library. Please run either 'composer install' or the 'install' script."); + } if(isset($getFileInfo['comments']['picture'][0])) {