mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW product images on popup are cached
This commit is contained in:
parent
aa459721b7
commit
ec83fe478f
|
|
@ -8767,9 +8767,10 @@ abstract class CommonObject
|
|||
* @param int $nolink Do not add a href link to view enlarged imaged into a new tab
|
||||
* @param int|string $overwritetitle Do not add title tag on image
|
||||
* @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead)
|
||||
* @param string $cache A string if we want to use a cached version of image
|
||||
* @return string Html code to show photo. Number of photos shown is saved in this->nbphoto
|
||||
*/
|
||||
public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $overwritetitle = 0, $usesharelink = 0)
|
||||
public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $overwritetitle = 0, $usesharelink = 0, $cache = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $user, $langs;
|
||||
|
|
@ -8854,13 +8855,11 @@ abstract class CommonObject
|
|||
if ($nbphoto % $nbbyrow == 1) {
|
||||
$return .= '<tr class="center valignmiddle" style="border: 1px">';
|
||||
}
|
||||
$return .= '<td style="width: '.ceil(100 / $nbbyrow).'%" class="photo">';
|
||||
$return .= '<td style="width: '.ceil(100 / $nbbyrow).'%" class="photo">'."\n";
|
||||
} elseif ($nbbyrow < 0) {
|
||||
$return .= '<div class="inline-block">';
|
||||
$return .= '<div class="inline-block">'."\n";
|
||||
}
|
||||
|
||||
$return .= "\n";
|
||||
|
||||
$relativefile = preg_replace('/^\//', '', $pdir.$photo);
|
||||
if (empty($nolink)) {
|
||||
$urladvanced = getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity);
|
||||
|
|
@ -8889,10 +8888,10 @@ abstract class CommonObject
|
|||
if ($val['share']) {
|
||||
if (empty($maxHeight) || ($photo_vignette && $imgarray['height'] > $maxHeight)) {
|
||||
$return .= '<!-- Show original file (thumb not yet available with shared links) -->';
|
||||
$return .= '<img class="photo photowithmargin'.($addphotorefcss ? ' photoref' : '').'"'.($maxHeight ?' height="'.$maxHeight.'"': '').' src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
$return .= '<img class="photo photowithmargin'.($addphotorefcss ? ' photoref' : '').'"'.($maxHeight ?' height="'.$maxHeight.'"': '').' src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).($cache ? '&cache='.urlencode($cache) : '').'" title="'.dol_escape_htmltag($alt).'">';
|
||||
} else {
|
||||
$return .= '<!-- Show original file -->';
|
||||
$return .= '<img class="photo photowithmargin'.($addphotorefcss ? ' photoref' : '').'" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
$return .= '<img class="photo photowithmargin'.($addphotorefcss ? ' photoref' : '').'" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).($cache ? '&cache='.urlencode($cache) : '').'" title="'.dol_escape_htmltag($alt).'">';
|
||||
}
|
||||
} else {
|
||||
$return .= '<!-- Show nophoto file (because file is not shared) -->';
|
||||
|
|
@ -8901,17 +8900,16 @@ abstract class CommonObject
|
|||
} else {
|
||||
if (empty($maxHeight) || ($photo_vignette && $imgarray['height'] > $maxHeight)) {
|
||||
$return .= '<!-- Show thumb -->';
|
||||
$return .= '<img class="photo photowithmargin'.($addphotorefcss ? ' photoref' : '').' maxwidth150onsmartphone maxwidth200"'.($maxHeight ?' height="'.$maxHeight.'"': '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
$return .= '<img class="photo photowithmargin'.($addphotorefcss ? ' photoref' : '').' maxwidth150onsmartphone maxwidth200"'.($maxHeight ?' height="'.$maxHeight.'"': '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.($cache ? '&cache='.urlencode($cache) : '').'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
} else {
|
||||
$return .= '<!-- Show original file -->';
|
||||
$return .= '<img class="photo photowithmargin'.($addphotorefcss ? ' photoref' : '').'" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
$return .= '<img class="photo photowithmargin'.($addphotorefcss ? ' photoref' : '').'" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.($cache ? '&cache='.urlencode($cache) : '').'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($nolink)) {
|
||||
$return .= '</a>';
|
||||
}
|
||||
$return .= "\n";
|
||||
|
||||
if ($showfilename) {
|
||||
$return .= '<br>'.$viewfilename;
|
||||
|
|
@ -8940,7 +8938,7 @@ abstract class CommonObject
|
|||
$return .= '</tr>';
|
||||
}
|
||||
} elseif ($nbbyrow < 0) {
|
||||
$return .= '</div>';
|
||||
$return .= '</div>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5032,10 +5032,9 @@ class Product extends CommonObject
|
|||
}
|
||||
|
||||
if (!empty($this->entity)) {
|
||||
$tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80);
|
||||
$tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80, 0, 0, 0, 0, 1);
|
||||
if ($this->nbphoto > 0) {
|
||||
$datas['photo'] = '<div class="photointooltip floatright">' . $tmpphoto . '</div>';
|
||||
//$label .= '<div style="clear: both;"></div>';
|
||||
$datas['photo'] = '<div class="photointooltip floatright">'."\n" . $tmpphoto . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5172,9 +5171,9 @@ class Product extends CommonObject
|
|||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowProduct");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"';
|
||||
}
|
||||
$linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
|
||||
$linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1, 1).'"' : ' title="tocomplete"');
|
||||
$linkclose .= $dataparams.' class="nowraponall '.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
|
||||
} else {
|
||||
$linkclose = ' class="nowraponall'.($morecss ? ' '.$morecss : '').'"';
|
||||
|
|
|
|||
|
|
@ -153,8 +153,8 @@ if ($modulepart == 'fckeditor') {
|
|||
*/
|
||||
|
||||
if (GETPOST("cache", 'alpha')) {
|
||||
// Important: Following code is to avoid page request by browser and PHP CPU at
|
||||
// each Dolibarr page access.
|
||||
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
|
||||
// Add param cache=abcdef
|
||||
if (empty($dolibarr_nocache)) {
|
||||
header('Cache-Control: max-age=3600, public, must-revalidate');
|
||||
header('Pragma: cache'); // This is to avoid having Pragma: no-cache
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user