문제

Is there any way to add other attributes to the image tag generated by TbImageColoumn ?

The documentation is not very clear on how to set image attributes like height, width etc. It only mentions on how to add image src using imagePathExpression attribute,

My current column looks like this

           .....
            array(
                'class'=>'bootstrap.widgets.TbImageColumn',
                'imagePathExpression'=>'$data->getImage("large")',
                'usePlaceKitten'=>false,
                ),
           .....
도움이 되었습니까?

해결책

Digging through the code it seems there is an attribute for setting html attributes to the generated tag using the imageOptions and to set attributes on generated td cell tag we can use the htmlOptions array from the base clase

/**
 * TbImageColumn widget class
 *
 * @package booster.widgets.grids.columns
 */
class TbImageColumn extends CGridColumn
{
    /**
     * @var array the HTML options of the image tag
     */
    public $imageOptions = array();

so to limit image width to 50px the column should be modified to

           .....
            array(
                'class'=>'bootstrap.widgets.TbImageColumn',
                'imagePathExpression'=>'$data->getImage("large")',
                'headerHtmlOptions'=>array('style'=>'min-width: 50px;'),
                'imageOptions'=>array('width'=>'50px'),
                'usePlaceKitten'=>false,
            ),
           .....
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top