Support of 'small', 'mini' and '' image size everywhere.
This commit is contained in:
parent
86db029cb3
commit
6dc6bab556
@ -5304,7 +5304,7 @@ class Form
|
||||
$entity = (! empty($object->entity) ? $object->entity : $conf->entity);
|
||||
$id = (! empty($object->id) ? $object->id : $object->rowid);
|
||||
|
||||
$ret='';$dir='';$file='';$altfile='';$email='';
|
||||
$ret='';$dir='';$file='';$originalfile='';$altfile='';$email='';
|
||||
|
||||
if ($modulepart=='societe')
|
||||
{
|
||||
@ -5313,9 +5313,11 @@ class Form
|
||||
$smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile);
|
||||
if (! empty($object->logo))
|
||||
{
|
||||
// TODO Introduce get_exdir
|
||||
if ((string) $imagesize == 'mini') $file=$id.'/logos/thumbs/'.getImageFileNameForSize($object->logo, '_mini');
|
||||
else if ((string) $imagesize == 'small') $file=$id.'/logos/thumbs/'.getImageFileNameForSize($object->logo, '_small');
|
||||
else $file=$id.'/logos/thumbs/'.$smallfile;
|
||||
$originalfile=$id.'/logos/thumbs/'.$smallfile;
|
||||
}
|
||||
}
|
||||
else if ($modulepart=='contact')
|
||||
@ -5323,9 +5325,11 @@ class Form
|
||||
$dir=$conf->societe->multidir_output[$entity].'/contact';
|
||||
if (! empty($object->photo))
|
||||
{
|
||||
// TODO Introduce get_exdir
|
||||
if ((string) $imagesize == 'mini') $file=$id.'/photos/thumbs/'.getImageFileNameForSize($object->photo, '_mini');
|
||||
else if ((string) $imagesize == 'small') $file=$id.'/photos/thumbs/'.getImageFileNameForSize($object->photo, '_small');
|
||||
else $file=$id.'/photos/'.$object->photo;
|
||||
$originalfile=$id.'/photos/'.$object->photo;
|
||||
}
|
||||
}
|
||||
else if ($modulepart=='userphoto')
|
||||
@ -5336,6 +5340,7 @@ class Form
|
||||
if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_mini');
|
||||
else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_small');
|
||||
else $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo;
|
||||
$originalfile=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo;
|
||||
}
|
||||
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
|
||||
$email=$object->email;
|
||||
@ -5348,6 +5353,7 @@ class Form
|
||||
if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_mini');
|
||||
else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_small');
|
||||
else $file=get_exdir($id, 2, 0, 0, $object, 'member').'photos/'.$object->photo;
|
||||
$originalfile=get_exdir($id, 2, 0, 0, $object, 'member').'photos/'.$object->photo;
|
||||
}
|
||||
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
|
||||
$email=$object->email;
|
||||
@ -5360,6 +5366,7 @@ class Form
|
||||
if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_mini');
|
||||
else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_small');
|
||||
else $file=get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo;
|
||||
$originalfile=get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo;
|
||||
}
|
||||
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
|
||||
$email=$object->email;
|
||||
@ -5369,13 +5376,13 @@ class Form
|
||||
{
|
||||
if ($file && file_exists($dir."/".$file))
|
||||
{
|
||||
if ($addlinktofullsize) $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
|
||||
if ($addlinktofullsize) $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
|
||||
$ret.='<img alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="'.$cssclass.'" '.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
|
||||
if ($addlinktofullsize) $ret.='</a>';
|
||||
}
|
||||
else if ($altfile && file_exists($dir."/".$altfile))
|
||||
{
|
||||
if ($addlinktofullsize) $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
|
||||
if ($addlinktofullsize) $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
|
||||
$ret.='<img alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="'.$cssclass.'" '.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($altfile).'&cache='.$cache.'">';
|
||||
if ($addlinktofullsize) $ret.='</a>';
|
||||
}
|
||||
|
||||
@ -892,7 +892,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
$showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
|
||||
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
|
||||
if ($conf->browser->phone) $maxvisiblephotos=1;
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],1,-$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',-$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
else
|
||||
{
|
||||
$nophoto='/public/theme/common/nophoto.png';
|
||||
@ -901,7 +901,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showphoto($modulepart,$object,0,0,0,'photoref','',1,0,$maxvisiblephotos).'</div>';
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showphoto($modulepart,$object,0,0,0,'photoref','small',1,0,$maxvisiblephotos).'</div>';
|
||||
}
|
||||
if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
|
||||
if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
||||
@ -5325,7 +5325,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
*
|
||||
* @param string $file Original filename (full or relative path)
|
||||
* @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini')
|
||||
* @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image.
|
||||
* @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image. Use '.png' for generated thumb files.
|
||||
* @return string New file name (full or relative path, including the thumbs/)
|
||||
*/
|
||||
function getImageFileNameForSize($file, $extName, $extImgTarget='')
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
-- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
|
||||
-- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
|
||||
-- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
|
||||
-- Note: fields with type BLOB/TEXT can't have default value.
|
||||
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
|
||||
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
||||
|
||||
|
||||
@ -3503,13 +3503,13 @@ class Product extends CommonObject
|
||||
* TODO Move this into html.formproduct.class.php
|
||||
*
|
||||
* @param string $sdir Directory to scan
|
||||
* @param int $size 0=original size, 1 use thumbnail if possible
|
||||
* @param int $size 0=original size, 1='small' use thumbnail if possible
|
||||
* @param int $nbmax Nombre maximum de photos (0=pas de max)
|
||||
* @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1.
|
||||
* @param int $showfilename 1=Show filename
|
||||
* @param int $showaction 1=Show icon with action links (resize, delete)
|
||||
* @param int $maxHeight Max height of image when size=1
|
||||
* @param int $maxWidth Max width of image when size=1
|
||||
* @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image.
|
||||
* @param int $maxWidth Max width of original image when size='small'
|
||||
* @param int $nolink Do not add a href link to view enlarged imaged into a new tab
|
||||
* @return string Html code to show photo. Number of photos shown is saved in this->nbphoto
|
||||
*/
|
||||
@ -3557,14 +3557,12 @@ class Product extends CommonObject
|
||||
$photo = $file;
|
||||
$viewfilename = $file;
|
||||
|
||||
if ($size == 1) { // Format vignette
|
||||
// On determine nom du fichier vignette
|
||||
$photo_vignette='';
|
||||
if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) {
|
||||
$photo_vignette=preg_replace('/'.$regs[0].'/i', '', $photo)."_small".$regs[0];
|
||||
if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette='';
|
||||
}
|
||||
if ($size == 1 || $size == 'small') { // Format vignette
|
||||
|
||||
// Find name of thumb file
|
||||
$photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small', '.png'));
|
||||
if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette='';
|
||||
|
||||
// Get filesize of original file
|
||||
$imgarray=dol_getImageSize($dir.$photo);
|
||||
|
||||
@ -3584,7 +3582,8 @@ class Product extends CommonObject
|
||||
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
|
||||
$alt=$langs->transnoentitiesnoconv('File').': '.$pdir.$photo;
|
||||
$alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
|
||||
if ($photo_vignette && $imgarray['height'] > $maxHeight)
|
||||
|
||||
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
|
||||
{
|
||||
$return.= '<!-- Show thumb -->';
|
||||
$return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
@ -3626,7 +3625,7 @@ class Product extends CommonObject
|
||||
else if ($nbbyrow < 0) $return.='</div>';
|
||||
}
|
||||
|
||||
if ($size == 0) { // Format origine
|
||||
if (empty($size)) { // Format origine
|
||||
$return.= '<img class="photo photowithmargin" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">';
|
||||
|
||||
if ($showfilename) $return.= '<br>'.$viewfilename;
|
||||
@ -3650,7 +3649,7 @@ class Product extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if ($size==1)
|
||||
if ($size==1 || $size='small')
|
||||
{
|
||||
if ($nbbyrow > 0)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user