Browse Source

Add an option for setting the quality of uploaded avatars

Visman 2 years ago
parent
commit
f579f91534

+ 1 - 0
app/Models/Pages/Admin/Install.php

@@ -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,

+ 9 - 0
app/Models/Pages/Admin/Options.php

@@ -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',
+                ],
             ],
         ];
 

+ 14 - 0
app/Models/Pages/Admin/Update.php

@@ -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;
+    }
 }

+ 1 - 0
app/Models/Pages/Profile/Edit.php

@@ -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);
 

+ 6 - 0
app/lang/en/admin_options.po

@@ -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"
 

+ 6 - 0
app/lang/ru/admin_options.po

@@ -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 "Почта"