Skip to content

Commit

Permalink
Implementing picking a random image from the templates
Browse files Browse the repository at this point in the history
Also removed 2 unused variables

Issue #72
  • Loading branch information
jeroenrnl committed Apr 6, 2016
1 parent 213da7a commit c7764f8
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions php/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,24 @@
} else if ($type==MID_PREFIX || $type==THUMB_PREFIX || empty($type)) {
$photo = new photo($photo_id);
$found = $photo->lookup();
} else if ($type=="background") {
$templates=array(
conf::get("interface.template"),
"default"
);
foreach($templates as $template) {
$bgs=glob(settings::$php_loc . "/templates/" . $template . "/images/backgrounds/*.{jpg,JPG}", GLOB_BRACE);
if(sizeof($bgs) > 0) {
$image=$bgs[array_rand($bgs)];
redirect("templates/" . $template . "/images/backgrounds/" . basename($image));
}
}
exit;
} else {
die("Illegal type");
}
if ($found) {
$name = $photo->get("name");
$image_path = conf::get("path.images") . "/" . $photo->get("path") . "/";
$watermark_file="";

if (!$user->isAdmin() && conf::get("watermark.enable")) {
$permissions = $user->getPhotoPermissions($photo);
$watermark = $permissions->get("watermark_level");
Expand Down

0 comments on commit c7764f8

Please sign in to comment.