NEW add image format avif (#37014)

* add format avif

* Update functions.lib.php
This commit is contained in:
Frédéric FRANCE 2026-01-28 16:19:01 +01:00 committed by GitHub
parent 27db2c8169
commit 11c2feb486
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 6 deletions

View file

@ -13,7 +13,7 @@
* Copyright (C) 2014 Cédric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019-2023 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
@ -13594,7 +13594,7 @@ function dolIsAllowedForPreview($file)
}
// Check mime types
$mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'webp', 'webm', 'mp4');
$mime_preview = array('avif', 'bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'webp', 'webm', 'mp4');
if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES')) {
$mime_preview[] = 'svg+xml';
}
@ -13875,6 +13875,10 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
$mime = 'video/webm';
$imgmime = 'video.png';
$famime = 'file-video';
} elseif (preg_match('/\.avif$/i', $tmpfile)) {
$mime = 'image/avif';
$imgmime = 'image.png';
$famime = 'file-image';
} elseif (preg_match('/\.avi$/i', $tmpfile)) {
$mime = 'video/x-msvideo';
$imgmime = 'video.png';

View file

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -121,6 +121,9 @@ function image_format_supported($file, $acceptsvg = 0)
if (strtolower($reg[1]) == '.svg') {
$imgfonction = 'imagecreatefromsvg'; // Never available
}
if (strtolower($reg[1]) == '.avif') {
$imgfonction = 'imagecreatefromavif'; // PHP >= 8.1
}
if ($imgfonction) {
if (!function_exists($imgfonction)) {
// Functions of conversion not available in this PHP