Merge pull request #13648 from annando/picture-upload
Allow to upload pictures up to the allowed system upload size
This commit is contained in:
commit
9901d82fea
|
@ -36,6 +36,7 @@ use Friendica\Core\System;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
use Friendica\Util\Images;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -282,7 +283,7 @@ class Page implements ArrayAccess
|
||||||
'$stylesheets' => $this->stylesheets,
|
'$stylesheets' => $this->stylesheets,
|
||||||
|
|
||||||
// Dropzone
|
// Dropzone
|
||||||
'$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($config->get('system', 'maximagesize')) / 1000000, 1),
|
'$max_imagesize' => round(Images::getMaxUploadBytes() / 1000000, 0),
|
||||||
|
|
||||||
]) . $this->page['htmlhead'];
|
]) . $this->page['htmlhead'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ class Display extends BaseSettings
|
||||||
$user = User::getById($uid);
|
$user = User::getById($uid);
|
||||||
|
|
||||||
$theme = trim($request['theme']);
|
$theme = trim($request['theme']);
|
||||||
$mobile_theme = trim($request['mobile_theme']);
|
$mobile_theme = trim($request['mobile_theme'] ?? '');
|
||||||
$enable_smile = (bool)$request['enable_smile'];
|
$enable_smile = (bool)$request['enable_smile'];
|
||||||
$enable = (array)$request['enable'];
|
$enable = (array)$request['enable'];
|
||||||
$bookmark = (array)$request['bookmark'];
|
$bookmark = (array)$request['bookmark'];
|
||||||
|
|
|
@ -244,22 +244,24 @@ class Images
|
||||||
$filesize = strlen($img_str);
|
$filesize = strlen($img_str);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$data = @getimagesizefromstring($img_str);
|
$data = (array)@getimagesizefromstring($img_str);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data) {
|
if (empty($data)) {
|
||||||
$image = new Image($img_str);
|
return [];
|
||||||
|
|
||||||
if ($image->isValid()) {
|
|
||||||
$data['blurhash'] = $image->getBlurHash();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['size'] = $filesize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_array($data) ? $data : [];
|
$image = new Image($img_str);
|
||||||
|
|
||||||
|
if ($image->isValid()) {
|
||||||
|
$data['blurhash'] = $image->getBlurHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['size'] = $filesize;
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -352,4 +354,15 @@ class Images
|
||||||
|
|
||||||
return '[img=' . $photo . ']' . $description . '[/img]';
|
return '[img=' . $photo . ']' . $description . '[/img]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the maximum possible upload size in bytes
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public static function getMaxUploadBytes(): int
|
||||||
|
{
|
||||||
|
$upload_size = ini_get('upload_max_filesize') ?: DI::config()->get('system', 'maximagesize');
|
||||||
|
return Strings::getBytesFromShorthand($upload_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user