I would like to know how I can show images (stored in a folder of my web-project) via a GridView in Yii2. The images are associated to an URL which is stored in a database …
-
MySQL -> Platform table: ID | Name | Img (Image’s URL)
-
View -> GridView which should show image from Image’s URL on MySQL
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Platforms';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="platform-index">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Create Platform', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id',
'name',
'img',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>