How To Set Image as Link in GridView

I can’t seem to find out how to link a thumbnail image in GridView to a view page.

On my model, I have the following method:

public function getThumbnailUrl()



        return Url::to($this->marketing_thumb_path, true);



And in the view I have:


           	'label' => 'Thumb',

           	'format' => 'image',

           	'value' => function ($model) { 

                              return $model->getThumbnailUrl(); 



And this works perfectly for displaying the thumbnail image, but I can’t figure out how to make that a clickable link to the view page. ‘format’ => ‘image’ wraps the value in an image tag, so if I do anything inside the closure, like using Html::a, the image tags end up in the wrong place.

There is probably an obvious and simple solution to this, but I’m just missing it. Can anyone help? I would appreciate it, thanks.

pretty straight forward here you go


public function getThumb()


        $image = \yii\helpers\Html::img('path/to/image.jpg');

        return \yii\helpers\Html::a($image, 'site/index');


// in your gridview you can just simply do like so


@alirz23 thanks!