mirror of
https://github.com/friendica/friendica
synced 2025-04-30 09:04:22 +02:00
Allow to upload pictures up to the allowed system upload size
This commit is contained in:
parent
5cf71baf55
commit
170998da1a
3 changed files with 26 additions and 12 deletions
|
@ -244,22 +244,24 @@ class Images
|
|||
$filesize = strlen($img_str);
|
||||
|
||||
try {
|
||||
$data = @getimagesizefromstring($img_str);
|
||||
$data = (array)@getimagesizefromstring($img_str);
|
||||
} catch (\Exception $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($data) {
|
||||
$image = new Image($img_str);
|
||||
|
||||
if ($image->isValid()) {
|
||||
$data['blurhash'] = $image->getBlurHash();
|
||||
}
|
||||
|
||||
$data['size'] = $filesize;
|
||||
if (empty($data)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
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]';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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…
Add table
Add a link
Reference in a new issue