From 7a224b127bbdba466c3301196c33964e022c4f6e Mon Sep 17 00:00:00 2001 From: Ceda EI <19731116+Ceda-EI@users.noreply.github.com> Date: Fri, 29 Dec 2017 11:00:41 +0530 Subject: [PATCH] Added an if-else to check for existance of preferences and accordingly modify the filters array. --- downloader.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/downloader.php b/downloader.php index a8b5f9f..6639774 100755 --- a/downloader.php +++ b/downloader.php @@ -13,11 +13,19 @@ $queries_file_name = getenv('HOME') . '/.config/lock_preferences'; $queries = file($queries_file_name); # Create the random photo limitations -$filters = [ - 'featured' => false, - 'query' => $queries[rand(0,count($queries) - 1)], - 'orientation' => 'landscape' -]; +if (count($queries) == 0){ + $filters = [ + 'featured' => false, + 'orientation' => 'landscape' + ]; +} +else { + $filters = [ + 'featured' => false, + 'query' => $queries[rand(0,count($queries) - 1)], + 'orientation' => 'landscape' + ]; +} # Get the random photo $img = Crew\Unsplash\Photo::random($filters);