Add function getListOfPossibleImageExt
This commit is contained in:
parent
638a4a6194
commit
f8b5bee9eb
@ -30,6 +30,23 @@ $maxheightmini = 72; // 16/9eme
|
|||||||
$quality = 80;
|
$quality = 80;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if a filename is file name of a supported image format
|
||||||
|
*
|
||||||
|
* @param int $acceptsvg 0=Default (depends on setup), 1=Always accept SVG as image files
|
||||||
|
* @return string Return list fo image format
|
||||||
|
*/
|
||||||
|
function getListOfPossibleImageExt($acceptsvg = 0)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
|
||||||
|
if ($acceptsvg || !empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
|
||||||
|
$regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript
|
||||||
|
}
|
||||||
|
|
||||||
|
return $regeximgext;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if a filename is file name of a supported image format
|
* Return if a filename is file name of a supported image format
|
||||||
@ -40,12 +57,7 @@ $quality = 80;
|
|||||||
*/
|
*/
|
||||||
function image_format_supported($file, $acceptsvg = 0)
|
function image_format_supported($file, $acceptsvg = 0)
|
||||||
{
|
{
|
||||||
global $conf;
|
$regeximgext = getListOfPossibleImageExt();
|
||||||
|
|
||||||
$regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
|
|
||||||
if ($acceptsvg || !empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
|
|
||||||
$regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript
|
|
||||||
}
|
|
||||||
|
|
||||||
// Case filename is not a format image
|
// Case filename is not a format image
|
||||||
$reg = array();
|
$reg = array();
|
||||||
|
|||||||
@ -2230,10 +2230,16 @@ if ($action == 'generatesitemaps' && $usercanedit) {
|
|||||||
}
|
}
|
||||||
$action = 'preview';
|
$action = 'preview';
|
||||||
}
|
}
|
||||||
|
|
||||||
$imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/image/'.$websitekey.'/';
|
$imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/image/'.$websitekey.'/';
|
||||||
|
|
||||||
if ($action == 'convertimgwebp' && $usercanedit) {
|
if ($action == 'convertimgwebp' && $usercanedit) {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||||
$filelist = dol_dir_list($imagefolder, "all", 1);
|
|
||||||
|
$regeximgext = getListOfPossibleImageExt();
|
||||||
|
|
||||||
|
$filelist = dol_dir_list($imagefolder, "all", 1, $regeximgext);
|
||||||
|
|
||||||
foreach ($filelist as $filename) {
|
foreach ($filelist as $filename) {
|
||||||
$filepath = $filename['fullname'];
|
$filepath = $filename['fullname'];
|
||||||
if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) {
|
if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user