Correzione visualizzazione allegati

This commit is contained in:
Dasc3er 2021-08-03 14:51:53 +02:00
parent 884da4fdae
commit e4148b634b
2 changed files with 8 additions and 5 deletions

View File

@ -206,7 +206,7 @@ class Upload extends Model
*/ */
public function isImage() public function isImage()
{ {
$list = ['jpg', 'png', 'gif', 'jpeg', 'bmp', 'svg']; $list = ['jpg', 'png', 'gif', 'jpeg', 'bmp'];
return in_array($this->extension, $list); return in_array($this->extension, $list);
} }

View File

@ -91,11 +91,14 @@ if ($file->isFatturaElettronica()) {
if ($file->isImage()) { if ($file->isImage()) {
echo ' echo '
<img src="'.$link.'"></img>'; <img src="'.$link.'"></img>';
} else { } elseif ($file->isPDF()) {
if ($file->isPDF()) { $preview = \Prints::getPDFLink($file->filepath);
$src = \Prints::getPDFLink($file->filepath);
}
echo '
<iframe src="'.($preview ?: $link).'">
<a src="'.$link.'">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a>
</iframe>';
} else {
echo ' echo '
<iframe src="'.base_path().'/view.php?file_id='.$file_id.'&download=1"> <iframe src="'.base_path().'/view.php?file_id='.$file_id.'&download=1">
<a src="'.base_path().'/view.php?file_id='.$file_id.'&download=1">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a> <a src="'.base_path().'/view.php?file_id='.$file_id.'&download=1">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a>