Add an option for setting the quality of uploaded avatars

This commit is contained in:
Visman 2023-06-03 14:43:21 +07:00
parent 6efd155597
commit f579f91534
6 changed files with 37 additions and 0 deletions

View file

@ -1468,6 +1468,7 @@ class Install extends Admin
'i_avatars_width' => 160,
'i_avatars_height' => 160,
'i_avatars_size' => 51200,
'i_avatars_quality' => 75,
'o_admin_email' => $v->email,
'o_webmaster_email' => $v->email,
'b_forum_subscriptions' => 1,

View file

@ -81,6 +81,7 @@ class Options extends Admin
'i_avatars_width' => 'required|integer|min:50|max:999',
'i_avatars_height' => 'required|integer|min:50|max:999',
'i_avatars_size' => 'required|integer|min:0|max:9999999',
'i_avatars_quality' => 'required|integer|min:0|max:100',
'o_admin_email' => 'required|string:trim|email',
'o_webmaster_email' => 'required|string:trim|email',
'b_forum_subscriptions' => 'required|integer|in:0,1',
@ -505,6 +506,14 @@ class Options extends Admin
'caption' => 'Max size label',
'help' => 'Max size help',
],
'i_avatars_quality' => [
'type' => 'number',
'min' => '0',
'max' => '100',
'value' => $config->i_avatars_quality,
'caption' => 'Avatar quality label',
'help' => 'Avatar quality help',
],
],
];

View file

@ -570,4 +570,18 @@ class Update extends Admin
return null;
}
/**
* rev.57 to rev.58
*/
protected function stageNumber57(array $args): ?int
{
$config = $this->c->config;
$config->i_avatars_quality = 75;
$config->save();
return null;
}
}

View file

@ -134,6 +134,7 @@ class Edit extends Profile
$result = $v->upload_avatar
->rename(true)
->rewrite(false)
->setQuality($this->c->config->i_avatars_quality ?? 75)
->resize($this->c->config->i_avatars_width, $this->c->config->i_avatars_height)
->toFile($path, $this->c->config->i_avatars_size);

View file

@ -237,6 +237,12 @@ msgstr "Max size"
msgid "Max size help"
msgstr "The maximum allowed size of avatars in bytes (10240 is recommended)."
msgid "Avatar quality label"
msgstr "Quality"
msgid "Avatar quality help"
msgstr "Avatar image quality between 0 and 100."
msgid "E-mail subhead"
msgstr "Email"

View file

@ -237,6 +237,12 @@ msgstr "Макс. размер"
msgid "Max size help"
msgstr "Макс. разрешённый размер аватары в байтах (рекомендуется 10240)."
msgid "Avatar quality label"
msgstr "Качество"
msgid "Avatar quality help"
msgstr "Качество изображения аватары от 0 до 100."
msgid "E-mail subhead"
msgstr "Почта"