$height = $Image->getHeight();
// create a new resource-id if not already provided
- $hash = ($photo_id == null) ? Photo::newResource() : $photo_id;
+ $resource_id = ($photo_id == null) ? Photo::newResource() : $photo_id;
if ($mediatype == "photo") {
// upload normal image (scales 0, 1, 2)
Logger::log("photo upload: starting new photo upload", Logger::DEBUG);
- $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 0, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 0, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
Logger::log("photo upload: image upload with scale 0 (original size) failed");
}
if ($width > 640 || $height > 640) {
$Image->scaleDown(640);
- $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 1, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 1, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
Logger::log("photo upload: image upload with scale 1 (640x640) failed");
}
if ($width > 320 || $height > 320) {
$Image->scaleDown(320);
- $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 2, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 2, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
Logger::log("photo upload: image upload with scale 2 (320x320) failed");
}
if ($width > 300 || $height > 300) {
$Image->scaleDown(300);
- $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 4, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 4, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
Logger::log("photo upload: profile image upload with scale 4 (300x300) failed");
}
if ($width > 80 || $height > 80) {
$Image->scaleDown(80);
- $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 5, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 5, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
Logger::log("photo upload: profile image upload with scale 5 (80x80) failed");
}
if ($width > 48 || $height > 48) {
$Image->scaleDown(48);
- $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 6, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 6, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
Logger::log("photo upload: profile image upload with scale 6 (48x48) failed");
}
if (isset($r) && $r) {
// create entry in 'item'-table on new uploads to enable users to comment/like/dislike the photo
if ($photo_id == null && $mediatype == "photo") {
- post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $filetype, $visibility);
+ post_photo_item($resource_id, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $filetype, $visibility);
}
// on success return image data in json/xml format (like /api/friendica/photo does when no scale is given)
- return prepare_photo_data($type, false, $hash);
+ return prepare_photo_data($type, false, $resource_id);
} else {
throw new InternalServerErrorException("image upload failed");
}
$smallest = 0;
- $photo_hash = Photo::newResource();
+ $resource_id = Photo::newResource();
- $r = Photo::store($image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
+ $r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if (!$r) {
Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG);
if ($width > 640 || $height > 640) {
$image->scaleDown(640);
- Photo::store($image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
+ Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$smallest = 1;
}
if ($width > 320 || $height > 320) {
$image->scaleDown(320);
- Photo::store($image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
+ Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$smallest = 2;
}
$arr['parent-uri'] = $uri;
$arr['type'] = 'photo';
$arr['wall'] = 1;
- $arr['resource-id'] = $photo_hash;
+ $arr['resource-id'] = $resource_id;
$arr['contact-id'] = $owner_record['id'];
$arr['owner-name'] = $owner_record['name'];
$arr['owner-link'] = $owner_record['url'];
$arr['visible'] = $visible;
$arr['origin'] = 1;
- $arr['body'] = '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
- . '[img]' . System::baseUrl() . "/photo/{$photo_hash}-{$smallest}.".$image->getExt() . '[/img]'
+ $arr['body'] = '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $resource_id . ']'
+ . '[img]' . System::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$image->getExt() . '[/img]'
. '[/url]';
$item_id = Item::insert($arr);
$width = $Image->getWidth();
$height = $Image->getHeight();
- $hash = Photo::newResource();
+ $resource_id = Photo::newResource();
$smallest = 0;
$defperm = '<' . $default_cid . '>';
- $r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 0, 0, $defperm);
+ $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0, 0, $defperm);
if (!$r) {
$msg = L10n::t('Image upload failed.');
if ($width > 640 || $height > 640) {
$Image->scaleDown(640);
- $r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 1, 0, $defperm);
+ $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, 0, $defperm);
if ($r) {
$smallest = 1;
}
if ($width > 320 || $height > 320) {
$Image->scaleDown(320);
- $r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 2, 0, $defperm);
+ $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, 0, $defperm);
if ($r && ($smallest == 0)) {
$smallest = 2;
}
$r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo`
WHERE `resource-id` = '%s'
ORDER BY `width` DESC LIMIT 1",
- $hash
+ $resource_id
);
if (!$r) {
if ($r_json) {
$picture["width"] = $r[0]["width"];
$picture["height"] = $r[0]["height"];
$picture["type"] = $r[0]["type"];
- $picture["albumpage"] = System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash;
- $picture["picture"] = System::baseUrl() . "/photo/{$hash}-0." . $Image->getExt();
- $picture["preview"] = System::baseUrl() . "/photo/{$hash}-{$smallest}." . $Image->getExt();
+ $picture["albumpage"] = System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id;
+ $picture["picture"] = System::baseUrl() . "/photo/{$resource_id}-0." . $Image->getExt();
+ $picture["preview"] = System::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $Image->getExt();
if ($r_json) {
echo json_encode(['picture' => $picture]);
exit();
}
- echo "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . System::baseUrl() . "/photo/{$hash}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
+ echo "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . System::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
exit();
// NOTREACHED
}
"photo", ["resource-id"], ["uid" => $uid, "contact-id" => $cid, "scale" => 4, "album" => "Contact Photos"]
);
if (!empty($photo['resource-id'])) {
- $hash = $photo["resource-id"];
+ $resource_id = $photo["resource-id"];
} else {
- $hash = self::newResource();
+ $resource_id = self::newResource();
}
$photo_failure = false;
if ($Image->isValid()) {
$Image->scaleToSquare(300);
- $r = self::store($Image, $uid, $cid, $hash, $filename, "Contact Photos", 4);
+ $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 4);
if ($r === false) {
$photo_failure = true;
$Image->scaleDown(80);
- $r = self::store($Image, $uid, $cid, $hash, $filename, "Contact Photos", 5);
+ $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 5);
if ($r === false) {
$photo_failure = true;
$Image->scaleDown(48);
- $r = self::store($Image, $uid, $cid, $hash, $filename, "Contact Photos", 6);
+ $r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 6);
if ($r === false) {
$photo_failure = true;
$suffix = "?ts=" . time();
- $image_url = System::baseUrl() . "/photo/" . $hash . "-4." . $Image->getExt() . $suffix;
- $thumb = System::baseUrl() . "/photo/" . $hash . "-5." . $Image->getExt() . $suffix;
- $micro = System::baseUrl() . "/photo/" . $hash . "-6." . $Image->getExt() . $suffix;
+ $image_url = System::baseUrl() . "/photo/" . $resource_id . "-4." . $Image->getExt() . $suffix;
+ $thumb = System::baseUrl() . "/photo/" . $resource_id . "-5." . $Image->getExt() . $suffix;
+ $micro = System::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix;
// Remove the cached photo
$a = \get_app();
$basepath = $a->getBasePath();
if (is_dir($basepath . "/photo")) {
- $filename = $basepath . "/photo/" . $hash . "-4." . $Image->getExt();
+ $filename = $basepath . "/photo/" . $resource_id . "-4." . $Image->getExt();
if (file_exists($filename)) {
unlink($filename);
}
- $filename = $basepath . "/photo/" . $hash . "-5." . $Image->getExt();
+ $filename = $basepath . "/photo/" . $resource_id . "-5." . $Image->getExt();
if (file_exists($filename)) {
unlink($filename);
}
- $filename = $basepath . "/photo/" . $hash . "-6." . $Image->getExt();
+ $filename = $basepath . "/photo/" . $resource_id . "-6." . $Image->getExt();
if (file_exists($filename)) {
unlink($filename);
}
if ($Image->isValid()) {
$Image->scaleToSquare(300);
- $hash = Photo::newResource();
+ $resource_id = Photo::newResource();
- $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 4);
+ $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 4);
if ($r === false) {
$photo_failure = true;
$Image->scaleDown(80);
- $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 5);
+ $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 5);
if ($r === false) {
$photo_failure = true;
$Image->scaleDown(48);
- $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 6);
+ $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 6);
if ($r === false) {
$photo_failure = true;
}
if (!$photo_failure) {
- Photo::update(['profile' => 1], ['resource-id' => $hash]);
+ Photo::update(['profile' => 1], ['resource-id' => $resource_id]);
}
}
}