Debug generation of webp
This commit is contained in:
parent
575d335374
commit
99d655b983
@ -148,10 +148,11 @@ function dol_getImageSize($file, $url = false)
|
|||||||
* @param int $src_x Position of croping image in source image (not use if mode=0)
|
* @param int $src_x Position of croping image in source image (not use if mode=0)
|
||||||
* @param int $src_y Position of croping image in source image (not use if mode=0)
|
* @param int $src_y Position of croping image in source image (not use if mode=0)
|
||||||
* @param string $filetowrite Path of file to write (overwrite source file if not provided)
|
* @param string $filetowrite Path of file to write (overwrite source file if not provided)
|
||||||
|
* @param int $newquality Value for the new quality of image, for supported format (use 0 for maximum/unchanged).
|
||||||
* @return string File name if OK, error message if KO
|
* @return string File name if OK, error message if KO
|
||||||
* @see dol_convert_file()
|
* @see dol_convert_file()
|
||||||
*/
|
*/
|
||||||
function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0, $filetowrite = '')
|
function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0, $filetowrite = '', $newquality = 0)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
|
||||||
@ -234,7 +235,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
|
|||||||
case 2: // Jpg
|
case 2: // Jpg
|
||||||
$img = imagecreatefromjpeg($filetoread);
|
$img = imagecreatefromjpeg($filetoread);
|
||||||
$extImg = '.jpg';
|
$extImg = '.jpg';
|
||||||
$newquality = 100; // % quality maximum
|
$newquality = ($newquality ? $newquality : '100'); // % quality maximum
|
||||||
break;
|
break;
|
||||||
case 3: // Png
|
case 3: // Png
|
||||||
$img = imagecreatefrompng($filetoread);
|
$img = imagecreatefrompng($filetoread);
|
||||||
@ -249,7 +250,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
|
|||||||
case 18: // Webp
|
case 18: // Webp
|
||||||
$img = imagecreatefromwebp($filetoread);
|
$img = imagecreatefromwebp($filetoread);
|
||||||
$extImg = '.webp';
|
$extImg = '.webp';
|
||||||
$newquality = '100'; // % quality maximum
|
$newquality = ($newquality ? $newquality : '100'); // % quality maximum
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,7 @@ print '<div class="inline-block toolbarbutton centpercent">';
|
|||||||
|
|
||||||
// Toolbar
|
// Toolbar
|
||||||
if ($permtoadd) {
|
if ($permtoadd) {
|
||||||
$websitekeyandpageid = (!empty($websitekey) ? '&website='.$websitekey : '').(!empty($pageid) ? '&pageid='.$pageid : '');
|
$websitekeyandpageid = (!empty($websitekey) ? '&website='.urlencode($websitekey) : '').(!empty($pageid) ? '&pageid='.urlencode($pageid) : '');
|
||||||
print '<a id="acreatedir" href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&module='.urlencode($module).$websitekeyandpageid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1'.$websitekeyandpageid).'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
|
print '<a id="acreatedir" href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&module='.urlencode($module).$websitekeyandpageid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1'.$websitekeyandpageid).'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
|
||||||
print img_picto('', 'folder-plus', '', false, 0, 0, '', 'size15x marginrightonly');
|
print img_picto('', 'folder-plus', '', false, 0, 0, '', 'size15x marginrightonly');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
@ -202,7 +202,7 @@ if ($action == 'convertimgwebp' && $permtoadd) {
|
|||||||
if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) {
|
if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) {
|
||||||
if (image_format_supported($filepath) == 1) {
|
if (image_format_supported($filepath) == 1) {
|
||||||
$filepathnoext = preg_replace("/\..*/", "", $filepath);
|
$filepathnoext = preg_replace("/\..*/", "", $filepath);
|
||||||
$result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp');
|
$result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp', 90);
|
||||||
if (!dol_is_file($result)) {
|
if (!dol_is_file($result)) {
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages($result, null, 'errors');
|
setEventMessages($result, null, 'errors');
|
||||||
@ -227,7 +227,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
|
|||||||
print '<!-- Title for manual directories -->'."\n";
|
print '<!-- Title for manual directories -->'."\n";
|
||||||
print '<tr class="liste_titre">'."\n";
|
print '<tr class="liste_titre">'."\n";
|
||||||
print '<th class="liste_titre left">';
|
print '<th class="liste_titre left">';
|
||||||
print ' '.$langs->trans("ECMSections");
|
print '<span style="padding-left: 5px; padding-right: 5px;">'.$langs->trans("ECMSections").'</span>';
|
||||||
print '</th></tr>';
|
print '</th></tr>';
|
||||||
|
|
||||||
$showonrightsize = '';
|
$showonrightsize = '';
|
||||||
@ -238,7 +238,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
|
|||||||
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
|
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
|
||||||
// Show the link to "Root"
|
// Show the link to "Root"
|
||||||
if ($showroot) {
|
if ($showroot) {
|
||||||
print '<tr><td><div style="padding-left: 5px; padding-right: 5px;"><a href="'.$_SERVER["PHP_SELF"].'?file_manager=1&pageid='.$pageid.'">';
|
print '<tr><td><div style="padding-left: 5px; padding-right: 5px;"><a href="'.$_SERVER["PHP_SELF"].'?file_manager=1'.(!empty($websitekey) ? '&website='.urlencode($websitekey) : '').'&pageid='.urlencode($pageid).'">';
|
||||||
if ($module == 'medias') {
|
if ($module == 'medias') {
|
||||||
print $langs->trans("RootOfMedias");
|
print $langs->trans("RootOfMedias");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user