From 0587f7a03579317a66f4be2173cd1f77417ab74c Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 19 Oct 2024 11:25:29 +0700 Subject: [PATCH] =?UTF-8?q?WIP:=20Added=20avif=20images=20support=20?= =?UTF-8?q?=F0=9F=8C=84=20(#1660)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * WIP: Added avif images support * Update CHANGELOG.md * Update admin_ranks.php --- CHANGELOG.md | 1 + admin/admin_ranks.php | 2 +- install/sql/mysql.sql | 1 + library/config.php | 7 ++++--- src/Legacy/BBCode.php | 2 +- src/Legacy/Common/Upload.php | 3 ++- styles/templates/posting_tpl.tpl | 4 ++-- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e117c8be3..6b76e7095 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Release 2.4.5 🦕 ([belomaxorka](https://github.com/belomaxorka)) - [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576), [\#1582](https://github.com/torrentpier/torrentpier/pull/1582), [\#1585](https://github.com/torrentpier/torrentpier/pull/1585), [\#1591](https://github.com/torrentpier/torrentpier/pull/1591) ([belomaxorka](https://github.com/belomaxorka)) +- Added avif images support 🌄 [\#1660](https://github.com/torrentpier/torrentpier/pull/1660) ([belomaxorka](https://github.com/belomaxorka)) - Added some new HTML meta-tags [\#1562](https://github.com/torrentpier/torrentpier/pull/1562) ([belomaxorka](https://github.com/belomaxorka)) - Added robots meta-tag support 🤖 [\#1587](https://github.com/torrentpier/torrentpier/pull/1587) ([belomaxorka](https://github.com/belomaxorka)) - Added [TorrServer](https://github.com/YouROK/TorrServer) instance support! 🎞 [\#1603](https://github.com/torrentpier/torrentpier/pull/1603), [\#1623](https://github.com/torrentpier/torrentpier/pull/1623), [\#1624](https://github.com/torrentpier/torrentpier/pull/1624), [\#1628](https://github.com/torrentpier/torrentpier/pull/1628) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/admin/admin_ranks.php b/admin/admin_ranks.php index 52feb13c3..b17637a95 100644 --- a/admin/admin_ranks.php +++ b/admin/admin_ranks.php @@ -83,7 +83,7 @@ if ($mode != '') { // The rank image has to be a jpg, gif or png // if ($rank_image != '') { - if (!preg_match('/(\.gif|\.png|\.jpg|\.jpeg|\.bmp|\.webp|\.ico)$/is', $rank_image)) { + if (!preg_match('/(\.gif|\.png|\.jpg|\.jpeg|\.bmp|\.webp|\.avif\.ico)$/is', $rank_image)) { $rank_image = ''; } } diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index 9c01caae0..641cc131d 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -701,6 +701,7 @@ VALUES ('1', 'gif', ''), ('1', 'jpeg', ''), ('1', 'jpg', ''), ('1', 'webp', ''), + ('1', 'avif', ''), ('1', 'bmp', ''), ('2', 'gtar', ''), ('2', 'gz', ''), diff --git a/library/config.php b/library/config.php index 8a45b75de..629f86e02 100644 --- a/library/config.php +++ b/library/config.php @@ -613,7 +613,8 @@ $bb_cfg['file_id_ext'] = [ 9 => 'zip', 10 => '7z', 11 => 'bmp', - 12 => 'webp' + 12 => 'webp', + 13 => 'avif' ]; // Attachments @@ -627,7 +628,7 @@ $bb_cfg['gen_forums_allowed_ext'] = ['zip', 'rar']; // TODO: For regular section // Avatars $bb_cfg['avatars'] = [ - 'allowed_ext' => ['gif', 'jpg', 'png', 'bmp', 'webp'], // Allowed file extensions (after changing, do the same for $bb_cfg['file_id_ext']) + 'allowed_ext' => ['gif', 'jpg', 'png', 'bmp', 'webp', 'avif'], // Allowed file extensions (after changing, do the same for $bb_cfg['file_id_ext']) 'bot_avatar' => '/gallery/bot.gif', // The bot's avatar 'max_size' => 100 * 1024, // Avatar's allowed dimensions 'max_height' => 100, // Avatar height in px @@ -640,7 +641,7 @@ $bb_cfg['avatars'] = [ // Group avatars $bb_cfg['group_avatars'] = [ - 'allowed_ext' => ['gif', 'jpg', 'png', 'bmp', 'webp'], // Allowed file extensions (add the same for $bb_cfg['file_id_ext']) + 'allowed_ext' => ['gif', 'jpg', 'png', 'bmp', 'webp', 'avif'], // Allowed file extensions (add the same for $bb_cfg['file_id_ext']) 'max_size' => 300 * 1024, // max avatar size in bytes 'max_height' => 300, // Avatar height in px 'max_width' => 300, // Avatar weight in px diff --git a/src/Legacy/BBCode.php b/src/Legacy/BBCode.php index cbe7dafc8..cd82f3788 100644 --- a/src/Legacy/BBCode.php +++ b/src/Legacy/BBCode.php @@ -78,7 +78,7 @@ class BBCode private function init_replacements(): void { $tpl = $this->tpl; - $img_exp = '(https?:)?//[^\s\?&;=\#\"<>]+?\.(jpg|jpeg|gif|png|bmp|webp)([a-z0-9/?&%;][^\[\]]*)?'; + $img_exp = '(https?:)?//[^\s\?&;=\#\"<>]+?\.(jpg|jpeg|gif|png|bmp|webp|avif)([a-z0-9/?&%;][^\[\]]*)?'; $email_exp = '[a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+'; $this->preg = [ diff --git a/src/Legacy/Common/Upload.php b/src/Legacy/Common/Upload.php index 7912a1292..c60154caf 100644 --- a/src/Legacy/Common/Upload.php +++ b/src/Legacy/Common/Upload.php @@ -86,7 +86,8 @@ class Upload IMAGETYPE_JPEG => 'jpg', IMAGETYPE_PNG => 'png', IMAGETYPE_BMP => 'bmp', - IMAGETYPE_WEBP => 'webp' + IMAGETYPE_WEBP => 'webp', + IMAGETYPE_AVIF => 'avif' ]; /** diff --git a/styles/templates/posting_tpl.tpl b/styles/templates/posting_tpl.tpl index 324e5d51c..1bd379ba2 100644 --- a/styles/templates/posting_tpl.tpl +++ b/styles/templates/posting_tpl.tpl @@ -374,8 +374,8 @@ var TPL = { reg: { num : /^\d+$/, URL : /^https?:\/\/[\w\#$%&~/.\-;:=?@\[\]+]+$/i, - img : /^https?:\/\/[^\s\?&;:=\#\"<>]+\.(jpg|jpeg|gif|png|bmp|webp)$/i, - img_tag : /(https?:\/\/[^\s\?&;:=\#\"<>]+\.(jpg|jpeg|gif|png|bmp|webp)(?!\[|\]|\.))/ig + img : /^https?:\/\/[^\s\?&;:=\#\"<>]+\.(jpg|jpeg|gif|png|bmp|webp|avif)$/i, + img_tag : /(https?:\/\/[^\s\?&;:=\#\"<>]+\.(jpg|jpeg|gif|png|bmp|webp|avif)(?!\[|\]|\.))/ig }, // построение сообщения на основе данных из формы