kopia lustrzana https://github.com/friendica/friendica
rodzic
fa14a02a19
commit
2f961b11bf
|
@ -157,9 +157,9 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
" - size: " . $filesize . " - type: " . $filetype);
|
" - size: " . $filesize . " - type: " . $filetype);
|
||||||
|
|
||||||
$imagedata = @file_get_contents($src);
|
$imagedata = @file_get_contents($src);
|
||||||
$Image = new Image($imagedata, $filetype);
|
$image = new Image($imagedata, $filetype);
|
||||||
|
|
||||||
if (!$Image->isValid()) {
|
if (!$image->isValid()) {
|
||||||
$msg = DI::l10n()->t('Unable to process image.');
|
$msg = DI::l10n()->t('Unable to process image.');
|
||||||
@unlink($src);
|
@unlink($src);
|
||||||
if ($r_json) {
|
if ($r_json) {
|
||||||
|
@ -170,18 +170,18 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
System::exit();
|
System::exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$Image->orient($src);
|
$image->orient($src);
|
||||||
@unlink($src);
|
@unlink($src);
|
||||||
|
|
||||||
$max_length = DI::config()->get('system', 'max_image_length');
|
$max_length = DI::config()->get('system', 'max_image_length');
|
||||||
if ($max_length > 0) {
|
if ($max_length > 0) {
|
||||||
$Image->scaleDown($max_length);
|
$image->scaleDown($max_length);
|
||||||
$filesize = strlen($Image->asString());
|
$filesize = strlen($image->asString());
|
||||||
Logger::info("File upload: Scaling picture to new size " . $max_length);
|
Logger::info("File upload: Scaling picture to new size " . $max_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
$width = $Image->getWidth();
|
$width = $image->getWidth();
|
||||||
$height = $Image->getHeight();
|
$height = $image->getHeight();
|
||||||
|
|
||||||
$maximagesize = DI::config()->get('system', 'maximagesize');
|
$maximagesize = DI::config()->get('system', 'maximagesize');
|
||||||
|
|
||||||
|
@ -190,10 +190,10 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
foreach ([5120, 2560, 1280, 640] as $pixels) {
|
foreach ([5120, 2560, 1280, 640] as $pixels) {
|
||||||
if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) {
|
if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) {
|
||||||
Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]);
|
Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]);
|
||||||
$Image->scaleDown($pixels);
|
$image->scaleDown($pixels);
|
||||||
$filesize = strlen($Image->asString());
|
$filesize = strlen($image->asString());
|
||||||
$width = $Image->getWidth();
|
$width = $image->getWidth();
|
||||||
$height = $Image->getHeight();
|
$height = $image->getHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($filesize > $maximagesize) {
|
if ($filesize > $maximagesize) {
|
||||||
|
@ -220,7 +220,7 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
|
|
||||||
$defperm = '<' . $default_cid . '>';
|
$defperm = '<' . $default_cid . '>';
|
||||||
|
|
||||||
$r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $defperm);
|
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $defperm);
|
||||||
|
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
$msg = DI::l10n()->t('Image upload failed.');
|
$msg = DI::l10n()->t('Image upload failed.');
|
||||||
|
@ -233,16 +233,16 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width > 640 || $height > 640) {
|
if ($width > 640 || $height > 640) {
|
||||||
$Image->scaleDown(640);
|
$image->scaleDown(640);
|
||||||
$r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $defperm);
|
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $defperm);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$smallest = 1;
|
$smallest = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width > 320 || $height > 320) {
|
if ($width > 320 || $height > 320) {
|
||||||
$Image->scaleDown(320);
|
$image->scaleDown(320);
|
||||||
$r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $defperm);
|
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $defperm);
|
||||||
if ($r && ($smallest == 0)) {
|
if ($r && ($smallest == 0)) {
|
||||||
$smallest = 2;
|
$smallest = 2;
|
||||||
}
|
}
|
||||||
|
@ -264,8 +264,8 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
$picture["height"] = $photo["height"];
|
$picture["height"] = $photo["height"];
|
||||||
$picture["type"] = $photo["type"];
|
$picture["type"] = $photo["type"];
|
||||||
$picture["albumpage"] = DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id;
|
$picture["albumpage"] = DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id;
|
||||||
$picture["picture"] = DI::baseUrl() . "/photo/{$resource_id}-0." . $Image->getExt();
|
$picture["picture"] = DI::baseUrl() . "/photo/{$resource_id}-0." . $image->getExt();
|
||||||
$picture["preview"] = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $Image->getExt();
|
$picture["preview"] = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt();
|
||||||
|
|
||||||
if ($r_json) {
|
if ($r_json) {
|
||||||
System::jsonExit(['picture' => $picture]);
|
System::jsonExit(['picture' => $picture]);
|
||||||
|
@ -280,7 +280,7 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
System::jsonExit(['ok' => true]);
|
System::jsonExit(['ok' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
|
echo "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt() . "[/img][/url]\n\n";
|
||||||
System::exit();
|
System::exit();
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue