/** * creates a correct field depending on the file type : * if the file is a picture, it will be displayed * if the file is anything else, a link to the resource will be displayed. * * @param $file string file to put in the row * @return string the file field */ public function fileField($file) { $filepath = $this->uploadConfig[(new \ReflectionClass($this->model))->getParentClass()->name]['file']['baseUrl'] . '/' . $this->model->file; $text = $file; if (in_array(strtolower(pathinfo($filepath)['extension']), ['jpg', 'png', 'gif', ''])) { $text = Html::img($filepath, ['alt' => isset($this->model->mediaI18ns[0]) ? $this->model->mediaI18ns[0]->title : $file, 'height' => '100px', 'class' => 'thumbnail center-block']); } return Html::a($text, $filepath, ['target' => '_blank']); }
<?php /** * @copyright Copyright (c) 2015 Kévin Walter <*****@*****.**> - Kalibao * @license https://github.com/kalibao/magesko/blob/master/LICENSE */ use kalibao\common\components\helpers\Html; ?> <tr class="form-inline"> <?php echo $this->render('crud/list/_gridBodyRowInlineActions', ['row' => $row], $this->context); ?> <td><?php echo $row->items['cms_image_i18n_title']; ?> </td> <td><?php echo $row->items['cms_image_group_i18n_title']; ?> </td> <td> <?php echo Html::img($row->uploadConfig[(new \ReflectionClass($row->model))->getParentClass()->name]['file_path']['baseUrl'] . '/min/' . $row->model->file_path, ['width' => '200px', 'class' => 'overview']); ?> </td> <?php echo $this->render('crud/list/_gridBodyRowActions', ['row' => $row], $this->context); ?> </tr>