use Friendica\Core\Theme;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
+use Friendica\Util\Images;
use Friendica\Util\Network;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
'$stylesheets' => $this->stylesheets,
// Dropzone
- '$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($config->get('system', 'maximagesize')) / 1000000, 1),
+ '$max_imagesize' => round(Images::getMaxUploadBytes() / 1000000, 0),
]) . $this->page['htmlhead'];
}
$user = User::getById($uid);
$theme = trim($request['theme']);
- $mobile_theme = trim($request['mobile_theme']);
+ $mobile_theme = trim($request['mobile_theme'] ?? '');
$enable_smile = (bool)$request['enable_smile'];
$enable = (array)$request['enable'];
$bookmark = (array)$request['bookmark'];
$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 (empty($data)) {
+ return [];
+ }
- if ($image->isValid()) {
- $data['blurhash'] = $image->getBlurHash();
- }
+ $image = new Image($img_str);
- $data['size'] = $filesize;
+ if ($image->isValid()) {
+ $data['blurhash'] = $image->getBlurHash();
}
- return is_array($data) ? $data : [];
+ $data['size'] = $filesize;
+
+ return $data;
}
/**
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);
+ }
}