diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index f04914ad85b..215e729a278 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -1445,7 +1445,25 @@ class FormFile
if (in_array($modulepart, array('product', 'produit', 'service'))) {
$newmodulepart = 'produit|service';
}
-
+ if (image_format_supported($file['name']) > 0) {
+ if ($permtoeditline) {
+ $moreparaminurl = '';
+ if (!empty($object->id) && $object->id > 0) {
+ $moreparaminurl .= '&id='.$object->id;
+ } elseif (GETPOST('website', 'alpha')) {
+ $moreparaminurl .= '&website='.GETPOST('website', 'alpha');
+ }
+ // Set the backtourl
+ if ($modulepart == 'medias' && !GETPOST('website')) {
+ $moreparaminurl .= '&backtourl='.urlencode(DOL_URL_ROOT.'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.'§ion_dir='.$relativepath);
+ }
+ if ($modulepart == 'medias' && !GETPOST('website')) {
+ print ''.img_picto('', 'images', 'class="flip marginrightonly"').'';
+ } elseif ($modulepart == 'medias' && GETPOST('website')) {
+ print ''.img_picto('', 'images', 'class="flip marginrightonly"').'';
+ }
+ }
+ }
if (!$disablecrop && image_format_supported($file['name']) > 0) {
if ($permtoeditline) {
// Link to resize
diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php
index b3edcb7984f..da73f5cd4b6 100644
--- a/htdocs/core/tpl/filemanager.tpl.php
+++ b/htdocs/core/tpl/filemanager.tpl.php
@@ -197,18 +197,22 @@ if ($action == 'confirmconvertimgwebp') {
$section_dir=GETPOST('section_dir', 'alpha');
$section=GETPOST('section', 'alpha');
+ $file=GETPOST('filetoregenerate', 'alpha');
$form = new Form($db);
$formquestion['section_dir']=array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir');
$formquestion['section']=array('type'=>'hidden', 'value'=>$section, 'name'=>'section');
+ $formquestion['filetoregenerate']=array('type'=>'hidden', 'value'=>$file, 'name'=>'filetoregenerate');
if ($module == 'medias') {
$formquestion['website']=array('type'=>'hidden', 'value'=>$website->ref, 'name'=>'website');
}
- print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('ConfirmImgWebpCreation'), $langs->trans('ConfirmGenerateImgWebp', $object->ref), 'convertimgwebp', $formquestion, "yes", 1);
+ print $form->formconfirm($_SERVER["PHP_SELF"], empty($file) ? $langs->trans('ConfirmImgWebpCreation') : $langs->trans('ConfirmChosenImgWebpCreation'), empty($file) ? $langs->trans('ConfirmGenerateImgWebp') : $langs->trans('ConfirmGenerateChosenImgWebp'), 'convertimgwebp', $formquestion, "yes", 1);
$action = 'file_manager';
}
// Duplicate images into .webp
if ($action == 'convertimgwebp' && $permtoadd) {
+ $file = GETPOST('filetoregenerate', 'alpha');
+
if ($module == 'medias') {
$imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/'.dol_sanitizePathName(GETPOST('section_dir', 'alpha'));
} else {
@@ -217,9 +221,14 @@ if ($action == 'convertimgwebp' && $permtoadd) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
- $regeximgext = getListOfPossibleImageExt();
+ if (!empty($file)) {
+ $filelist = array();
+ $filelist[]["fullname"] = dol_osencode($imagefolder.'/'.$file); // get $imagefolder.'/'.$file infos
+ } else {
+ $regeximgext = getListOfPossibleImageExt();
- $filelist = dol_dir_list($imagefolder, "files", 0, $regeximgext);
+ $filelist = dol_dir_list($imagefolder, "files", 0, $regeximgext);
+ }
$nbconverted = 0;
@@ -245,7 +254,11 @@ if ($action == 'convertimgwebp' && $permtoadd) {
}
}
if (!$error) {
- setEventMessages($langs->trans('SucessConvertImgWebp'), null);
+ if (!empty($file)) {
+ setEventMessages($langs->trans('SucessConvertChosenImgWebp'), null);
+ } else {
+ setEventMessages($langs->trans('SucessConvertImgWebp'), null);
+ }
}
$action = 'file_manager';
}
diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang
index 724e5aa59d7..2e88812681d 100644
--- a/htdocs/langs/en_US/ecm.lang
+++ b/htdocs/langs/en_US/ecm.lang
@@ -47,6 +47,10 @@ ECMSetup=ECM Setup
GenerateImgWebp=Duplicate all images with another version with .webp format
ConfirmGenerateImgWebp=If you confirm, you will generate an image in .webp format for all images currently into this folder (subfolders are not included)...
ConfirmImgWebpCreation=Confirm all images duplication
+GenerateChosenImgWebp=Duplicate chosen image with another version with .webp format
+ConfirmGenerateChosenImgWebp=If you confirm, you will generate an image in .webp format for chosen image
+ConfirmChosenImgWebpCreation=Confirm chosen images duplication
SucessConvertImgWebp=Images successfully duplicated
+SucessConvertChosenImgWebp=Chosen image successfully duplicated
ECMDirName=Dir name
ECMParentDirectory=Parent directory