From cb89942bfbf267d7bbb93759d089eec4b156164b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Sep 2018 16:03:10 +0200 Subject: [PATCH] Add option capture on input file for photo --- htdocs/core/class/html.form.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 550ecea4867..27d7fe521fe 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6674,16 +6674,17 @@ class Form * @param string $imagesize 'mini', 'small' or '' (original) * @param int $addlinktofullsize Add link to fullsize image * @param int $cache 1=Accept to use image in cache + * @param string $forcecapture Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if empty. * @return string HTML code to output photo */ - static function showphoto($modulepart, $object, $width=100, $height=0, $caneditfield=0, $cssclass='photowithmargin', $imagesize='', $addlinktofullsize=1, $cache=0) + static function showphoto($modulepart, $object, $width=100, $height=0, $caneditfield=0, $cssclass='photowithmargin', $imagesize='', $addlinktofullsize=1, $cache=0, $forcecapture='') { global $conf,$langs; $entity = (! empty($object->entity) ? $object->entity : $conf->entity); $id = (! empty($object->id) ? $object->id : $object->rowid); - $ret='';$dir='';$file='';$originalfile='';$altfile='';$email=''; + $ret='';$dir='';$file='';$originalfile='';$altfile='';$email='';$capture=''; if ($modulepart=='societe') { $dir=$conf->societe->multidir_output[$entity]; @@ -6707,6 +6708,7 @@ class Form $originalfile=get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo; } $email=$object->email; + $capture='user'; } else if ($modulepart=='userphoto') { @@ -6720,6 +6722,7 @@ class Form } if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; + $capture='user'; } else if ($modulepart=='memberphoto') { @@ -6733,6 +6736,7 @@ class Form } if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; + $capture='user'; } else { @@ -6749,6 +6753,8 @@ class Form $email=$object->email; } + if ($forcecapture) $capture = $forcecapture; + if ($dir) { if ($file && file_exists($dir."/".$file)) @@ -6805,7 +6811,7 @@ class Form if ($object->photo) $ret.="
\n"; $ret.=''; if ($object->photo) $ret.=''; - $ret.=''; + $ret.=''; $ret.='
'.$langs->trans("Delete").'

'; }