changes to implement eldy's advices

This commit is contained in:
lmarcouiller 2021-04-28 09:22:10 +02:00
parent c1069c5f16
commit 7782e849e2

View File

@ -99,12 +99,14 @@ if ($permtoadd && $module == 'ecm') { // If on file manager medias in ecm
print "<script> print "<script>
$(\"#generateimgwebp\").on(\"click\",function(){ $(\"#generateimgwebp\").on(\"click\",function(){
try{ try{
console.log(\"We click to generate webp image, we set current dir into hidden vars\");
section_dir = $(\".directory.expanded\")[$(\".directory.expanded\").length-1].children[0].rel section_dir = $(\".directory.expanded\")[$(\".directory.expanded\").length-1].children[0].rel
section=$(\".directory.expanded\")[$(\".directory.expanded\").length-1].children[0].id.split('_')[2] section=$(\".directory.expanded\")[$(\".directory.expanded\").length-1].children[0].id.split('_')[2]
}catch{ }catch{
section_dir = '/' section_dir = '/'
section=0 section=0
} }
console.log(\"We add hiden vars in href of button to create webp \");
$(\"#generateimgwebp\").attr(\"href\",$(\"#generateimgwebp\").attr(\"href\")+'&section_dir='+section_dir+'&section='+section) $(\"#generateimgwebp\").attr(\"href\",$(\"#generateimgwebp\").attr(\"href\")+'&section_dir='+section_dir+'&section='+section)
}) })
</script>"; </script>";
@ -170,9 +172,9 @@ if ($action == 'confirmconvertimgwebp') {
if ($action == 'convertimgwebp' && $permtoadd) { if ($action == 'convertimgwebp' && $permtoadd) {
if ($module == 'medias') { if ($module == 'medias') {
$imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/'.GETPOST('section_dir', 'alpha'); $imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/'.dol_sanitizeFileName(GETPOST('section_dir', 'alpha'));
} else { } else {
$imagefolder = $conf->ecm->dir_output.'/'.GETPOST('section_dir', 'alpha'); $imagefolder = $conf->ecm->dir_output.'/'.dol_sanitizePathName(GETPOST('section_dir', 'alpha'));
} }
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';