Added an if-else to check for existance of preferences and accordingly modify the filters array.

This commit is contained in:
Ceda EI 2017-12-29 11:00:41 +05:30
parent 5726684c00
commit 7a224b127b
1 changed files with 13 additions and 5 deletions

View File

@ -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);