formatBytes calls
implement function in new class
This commit is contained in:
parent
b73af72deb
commit
46d7767fd0
5 changed files with 8 additions and 6 deletions
|
@ -4500,7 +4500,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
||||||
// check against max upload size within Friendica instance
|
// check against max upload size within Friendica instance
|
||||||
$maximagesize = Config::get('system', 'maximagesize');
|
$maximagesize = Config::get('system', 'maximagesize');
|
||||||
if ($maximagesize && ($filesize > $maximagesize)) {
|
if ($maximagesize && ($filesize > $maximagesize)) {
|
||||||
$formattedBytes = formatBytes($maximagesize);
|
$formattedBytes = Strings::formatBytes($maximagesize);
|
||||||
throw new InternalServerErrorException("image size exceeds Friendica config setting (uploaded size: $formattedBytes)");
|
throw new InternalServerErrorException("image size exceeds Friendica config setting (uploaded size: $formattedBytes)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -780,7 +780,7 @@ function photos_post(App $a)
|
||||||
notice(L10n::t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL);
|
notice(L10n::t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL);
|
||||||
break;
|
break;
|
||||||
case UPLOAD_ERR_FORM_SIZE:
|
case UPLOAD_ERR_FORM_SIZE:
|
||||||
notice(L10n::t('Image exceeds size limit of %s', formatBytes(defaults($_REQUEST, 'MAX_FILE_SIZE', 0))) . EOL);
|
notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes(defaults($_REQUEST, 'MAX_FILE_SIZE', 0))) . EOL);
|
||||||
break;
|
break;
|
||||||
case UPLOAD_ERR_PARTIAL:
|
case UPLOAD_ERR_PARTIAL:
|
||||||
notice(L10n::t('Image upload didn\'t complete, please try again') . EOL);
|
notice(L10n::t('Image upload didn\'t complete, please try again') . EOL);
|
||||||
|
@ -809,7 +809,7 @@ function photos_post(App $a)
|
||||||
$maximagesize = Config::get('system', 'maximagesize');
|
$maximagesize = Config::get('system', 'maximagesize');
|
||||||
|
|
||||||
if ($maximagesize && ($filesize > $maximagesize)) {
|
if ($maximagesize && ($filesize > $maximagesize)) {
|
||||||
notice(L10n::t('Image exceeds size limit of %s', formatBytes($maximagesize)) . EOL);
|
notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL);
|
||||||
@unlink($src);
|
@unlink($src);
|
||||||
$foo = 0;
|
$foo = 0;
|
||||||
Addon::callHooks('photo_post_end', $foo);
|
Addon::callHooks('photo_post_end', $foo);
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Friendica\Model\Photo;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Util\Security;
|
use Friendica\Util\Security;
|
||||||
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
function profile_photo_init(App $a)
|
function profile_photo_init(App $a)
|
||||||
{
|
{
|
||||||
|
@ -151,7 +152,7 @@ function profile_photo_post(App $a)
|
||||||
$maximagesize = Config::get('system', 'maximagesize');
|
$maximagesize = Config::get('system', 'maximagesize');
|
||||||
|
|
||||||
if (($maximagesize) && ($filesize > $maximagesize)) {
|
if (($maximagesize) && ($filesize > $maximagesize)) {
|
||||||
notice(L10n::t('Image exceeds size limit of %s', formatBytes($maximagesize)) . EOL);
|
notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL);
|
||||||
@unlink($src);
|
@unlink($src);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Mimetype;
|
use Friendica\Util\Mimetype;
|
||||||
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
function wall_attach_post(App $a) {
|
function wall_attach_post(App $a) {
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ function wall_attach_post(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($maxfilesize && $filesize > $maxfilesize) {
|
if ($maxfilesize && $filesize > $maxfilesize) {
|
||||||
$msg = L10n::t('File exceeds size limit of %s', formatBytes($maxfilesize));
|
$msg = L10n::t('File exceeds size limit of %s', Strings::formatBytes($maxfilesize));
|
||||||
if ($r_json) {
|
if ($r_json) {
|
||||||
echo json_encode(['error' => $msg]);
|
echo json_encode(['error' => $msg]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -194,7 +194,7 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
$maximagesize = Config::get('system', 'maximagesize');
|
$maximagesize = Config::get('system', 'maximagesize');
|
||||||
|
|
||||||
if (($maximagesize) && ($filesize > $maximagesize)) {
|
if (($maximagesize) && ($filesize > $maximagesize)) {
|
||||||
$msg = L10n::t('Image exceeds size limit of %s', formatBytes($maximagesize));
|
$msg = L10n::t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize));
|
||||||
if ($r_json) {
|
if ($r_json) {
|
||||||
echo json_encode(['error' => $msg]);
|
echo json_encode(['error' => $msg]);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue