location_id != $location_id) throw new Exception("Photo not found."); $location = Location::get($location_id); } else { $location = Location::get($location_id); if(!$location) throw new Exception("Location not found."); $photo = LocationFile::queryOne([ "location_id" => $location->id, "type" => LocationFile::TYPE_PHOTO ]); if(!$photo) { header("Content-Type: image/png"); readfile("public/img/no_image_4_3.png"); exit; } $id = $photo->id; } $path = $location->getDirectory() . "/$id.jpg"; if(!file_exists($path)) HTTP::redirect("/img/blank.png"); header("Content-Type: image/jpeg"); readfile($path);