images Display the image on view file

Hi Friends,

This is my first Extension created how to display image on view file using extension

First you can create the function folder in protected/extersions/functions and also create the images folder on your root directory

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 height='150px' width='150px' 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);
3 2
Yii Version: all
License: (not set)
Category: File System
Developed by: Ankit Modi
Created on: Jul 3, 2013
Last updated: 9 years ago

Related Extensions