Beispiel #1
0
 /**
  * @return string
  */
 public function getUrl()
 {
     return $this->photo->getUrl(Photo::THUMBNAIL_SMALL);
 }
 /**
  * @param \FlickrDownloadr\Photo\Photo $photo
  * @return string
  */
 private function getExtension(Photo $photo)
 {
     $url = $photo->getUrl();
     return pathinfo($url, PATHINFO_EXTENSION);
 }
Beispiel #3
0
$contestId = $_POST['contest_id'] !== null ? $_POST['contest_id'] : $_GET['contest_id'];
$contest = Contest::loadContest($contestId);
npadmin_security($contest->getAllowedGroups(), false, _("You are not invited to this contest") . " (ID: " . $contestId . ")", true);
if ($_POST['op'] == 'upload') {
    if ($_FILES['photoFile']['error'] === 0) {
        if ($contest->status === STATUS_OPEN) {
            $photos = $contest->photosOfUser($userId);
            if (count($photos) < $contest->numberPhotos) {
                $photo = new Photo();
                $photo->userId = $userId;
                $photo->contestId = $contestId;
                $photo->title = $_POST['title'];
                $photo->description = $_POST['description'];
                $photo->exif = read_exif_data($_FILES['photoFile']['tmp_name']);
                if ($photo->store()) {
                    $photo_filename = "../" . $photo->getUrl();
                    $photo_filename_thumb = "../" . $photo->getThumbUrl();
                    if (move_uploaded_file($_FILES['photoFile']['tmp_name'], $photo_filename)) {
                        $image = new NP_Image($photo_filename);
                        $image_resized = $image->resizeMaxSize(1024);
                        $image_resized->save($photo_filename);
                        $image_thumb = $image->resizeMaxSize(240);
                        if ($image_thumb->save($photo_filename_thumb)) {
                            echo "OK: " . $photo_filename;
                        } else {
                            echo _("ERROR: Could not create thumbnail");
                        }
                        $image->close();
                        $image_resized->close();
                        $image_thumb->close();
                    } else {