This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| // There and next: | |
| // webroot.images - path to images forlder (such as Yii::app()->baseurl."/images/") | |
| // if using another forder name (for example: /upload/) - Yii::getPathOfAlias('webroot.upload') | |
| // file_field_name - db field that contains name of uploaded file | |
| // DIRECTORY_SEPARATOR - separator, such as "/" or included folders | |
| // PATH_TO_IMAGE_FOLDER - full path to folder with images | |
| // Previously added CImageHandler and Fancybox extensions | |
| // CImageHandler: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add to current model | |
| protected function beforeDelete() | |
| { | |
| if (parent::beforeDelete()) { | |
| // file_field_name - db field that contains name of uploaded file | |
| if ($this-><file_field_name>) | |
| // webroot.images - path to images forlder (such as Yii::app()->baseurl."/images/") | |
| // if using another forder name (for example: /upload/) - Yii::getPathOfAlias('webroot.upload') | |
| @unlink(Yii::getPathOfAlias('webroot.images') . "DIRECTOTY_SEPARATOR" . $this-><file_field_name>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| echo !empty($model-><field>) && file_exists(Yii::getPathOfAlias('webroot.images')."<PATH>".$model-><field>) ? CHtml::image(Yii::app()->baseurl."<PATH>".$model-><field>,"",array("style"=>"width:50px;height:50px;align:center;")) : CHtml::image(Yii::app()->baseurl."/<PATH>/no_img.png","",array("style"=>"width:50px;height:50px;align:center;")); | |
| ?> |
NewerOlder