Skip to content

Commit ab23acb

Browse files
committed
feat: Gestione immagini nelle viste
1 parent 60349f5 commit ab23acb

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

ajax_dataload.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
include_once __DIR__.'/core.php';
2222

2323
use Util\Query;
24+
use Models\Module;
2425

2526
// Informazioni fondamentali
2627
$columns = (array) filter('columns', null, true);
@@ -181,6 +182,22 @@
181182
$value = '<a href="'.$print_url.'" target="_blank"><i class="fa fa-2x fa-print"></i></a>';
182183
}
183184

185+
// Immagine
186+
elseif ($field == '_img_') {
187+
$module = Module::where('id', $id_module)->first();
188+
if( !empty($r['_img_']) ){
189+
$fileinfo = \Uploads::fileInfo($r['_img_']);
190+
191+
$directory = '/'.$module->upload_directory.'/';
192+
$image = $directory.$r['_img_'];
193+
$image_thumbnail = $directory.$fileinfo['filename'].'_thumb600.'.$fileinfo['extension'];
194+
195+
$url = file_exists(base_dir().$image_thumbnail) ? base_path().$image_thumbnail : base_path().$image;
196+
197+
$value = '<img src="'.$url.'" style="max-height: 80px; max-width:120px">';
198+
}
199+
}
200+
184201
// Icona
185202
elseif (preg_match('/^icon_(.+?)$/', trim($field), $m)) {
186203
$value = '<span class=\'badge text-black\' style=\'font-weight:normal;\' ><i class="'.$r[$field].'" title="'.$r['icon_title_'.$m[1]].'" ></i> <span>'.$r['icon_title_'.$m[1]].'</span></span>';

include/manager.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@
121121
$attr_td .= " width='100'";
122122
}
123123

124+
//Immagine
125+
elseif (trim((string) $field) == '_img_') {
126+
$attr_td .= " width='30'";
127+
$field = str_replace('_img_', '', $field);
128+
}
129+
124130
// Icona di stampa
125131
elseif (trim((string) $field) == '_print_') {
126132
$attr_td .= " width='30'";

0 commit comments

Comments
 (0)