Answer the question
In order to leave comments, you need to log in
Yii2 - GridView - how to display an image?
Hello everyone, tell me how to display an image in a GridView
I use costa-rico (link to git in the comments)
array(
'format' => 'image',
'value'=>function($data) { return $data->imageurl; },
),
public function getImageurl()
{
$category = Category::find()->one();
$img = $category->getImage();
return $img->getUrl();
}
Answer the question
In order to leave comments, you need to log in
$category = Category::find()->andWhere(['id'=>$this->category_id])->one();
if (!$category) {
return null;
}
$img = $category->getImage()
return $img->getUrl();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question