How to insert image

please help us what is the code for inserting image in Yii Framework.

not for label image, but pure image only. help us pls.

If you want to generate an html image, use CHtml::image()

can u give us some example, specific example for :

public static string image(string $src, string $alt=’’, array $htmlOptions=array ( ))

CHtml::image("/images/img1.png","Alt Text for Image");

Sir, for example this code. can u make it into a specific example how to insert image?

public static function image($src,$alt=’’,$htmlOptions=array())




return self::tag('img',$htmlOptions);


The user rymonator has already posted an example how to use that function… you call the function with CHtml::image()… first parameter is the image path… and second parameter is the alt text for the image… you call that function inside the view file… and at that place a <IMG … /> tag will be generated…

If that does not explain all you need… please explain better… what you need to accomplish…

hello, may be this

  public static function Image ($img,$alt=NULL,$options=array()){

   $alt= 'an image thumbnail';



   return CHtml::image($img,$alt,$options);


i hope u are now clear ::)


You did not put a name for your function :)

thanks, Just fixed it now. <_<