Create Extension

Hi Friends,

This is my first Extension created how to call a image in view file

First you can create the folder in protected/extersions/functions and in create the images folder in your root

In Functions folder created the Functions.php and write a code


class Functions extends CApplicationComponent {

	public function returnSomething($filePath,$image){



		$folder=$path. $filePath.'/images/'.$image;

		if ($image!='' && file_exists(YiiBase::getPathOfAlias('webroot') . $filePath)) {

			$filePath= "<img src='".$folder."'>";

		} else {

			$filePath="<img src=''>";


		return $filePath;




Finally install this extension in config/main.php






and use this extension using this line

print Yii::app()->functions->returnSomething($filePath='',$image);

in $image is your data image so u can fetch image in $image varibale

for exampleā€¦


$image= $vendor->image_name;

print Yii::app()->functions->returnSomething($filePath='',$image);

more refrence

Hope it will be helpful

Best Regards,

Ankit Modi