Added an if-else to check for existance of preferences and accordingly modify the filters array.
This commit is contained in:
parent
5726684c00
commit
7a224b127b
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue