This column assumes that the filename is saved as a path to the image that is to be rendered. If no pathPrefix is given, it assumes Yii::app()->baseUrl as a prefix for the image.
Installation ¶
extract the file to your application components/ directory.
Example Usage ¶
Yii::import('application.components.EImageColumn');
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'photo-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
array(
'class'=>'EImageColumn',
'name' => 'filename',
'htmlOptions' => array('style' => 'width: 150px;'),
),
'album.title',
'album.category.title',
'title',
'filename',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Another implementation
I've created another implementation a while ago.
samdark´ s implementation
Nice. Would i have found your ImageColumn, i would had used yours rather than
doing a own. Your 'imagePathExpression' idea may be better than mine, it allows for more flexible path constructions ;)
Awesome
nice job
Change on 'name' attribute
Hi
I've changed renderDataCellContent function, to support names with relations, like 'name'=>'Post.Author'
//$image = CHtml::image($this->pathPrefix . $data->{$this->name} . $this->pathSuffix, $image = CHtml::image($this->pathPrefix . CHtml::value($data,$this->name) . $this->pathSuffix,
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.