Interesting Controller. I made some modifications to set the cache directory to the assets directory and I modified the ‘crop’ parameter to ‘false’ by default.
I also extend CHtml in my project and I modified ‘image’ like this:
class YHtml5 {
/**
* Generates an image tag.
* @param string $src the image URL
* @param string $alt the alternative text display
* @param array $htmlOptions additional HTML attributes (see {@link tag}).
* Add height and/or width to enable automatic image resizing.
* @return string the generated image tag
*/
public static function image($src,$alt='',$htmlOptions=array())
{
if(!strncmp($src,'/',1)) {
$params=array('image'=>$src);
if(isset($htmlOptions['height'])) {
$params['height']=$htmlOptions['height'];
}
if(isset($htmlOptions['width'])) {
$params['width']=$htmlOptions['width'];
}
if(count($params)!=1) {
$src=Yii::app()->createUrl('image/get',$params);
}
}
$htmlOptions['src']=$src;
$htmlOptions['alt']=$alt;
return self::tag('img',$htmlOptions);
}
[size=2]}[/size]