Yii Framework Forum: Cthumbcreator - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cthumbcreator to create and save Thumbnail Images From The uploaded image Rate Topic: -----

#1 User is offline   nidaIngress 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 20-February 14

Posted 11 June 2014 - 12:35 AM

hi i have followed CThumbCreator extension

and have put CThumbCreator.php file in protected->extensions->CThumbCreator.php and in main.php i have written this :
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
'simple_image'=>array(
'class' => 'application.extensions.CSimpleImage',
),
'components'=>array(
'thumb'=>array(
'class'=>'application.extensions.CThumbCreator',
'width' => 160,
'height'=> 160,
'prefix'=>'img',
'defaultName' => "mythumb",
'directory' => "uploads/small"
)
),

and in MyController file i have used this code:
public function actionAddDirectors()
{
$modelDirectors = new BoardOfDirectors;
$imagetime=time();
if(isset($_POST['BoardOfDirectors']))
{ $modelDirectors->attributes= $_POST['BoardOfDirectors'];
define('UPLOADED_IMAGE_DESTINATION', './uploads/');
//define('NORMAL_IMAGE_DESTINATION', './uploads/normal/');
define('THUMBNAIL_IMAGE_DESTINATION', './uploads/small/');
define('THUMBNAIL_IMAGE_MAX_WIDTH',160);
define('THUMBNAIL_IMAGE_MAX_HEIGHT',160);
$modelDirectors->image = CUploadedFile::getInstanceByName("image");
$modelDirectors->image->saveAs(UPLOADED_IMAGE_DESTINATION.$imagetime.CUploadedFile::getInstanceByName("image"));
$type=$modelDirectors->image->extensionName;
$thumbNew = Yii::app()->thumb;
$thumbNew->image = CUploadedFile::getInstanceByName("image");
$thumbNew->width = 160;
$thumbNew->height = 160;

$thumbNew->createThumb();
$thumbNew->directory = THUMBNAIL_IMAGE_DESTINATION;
$thumbNew->save();


$modelDirectors->name = $_POST['BoardOfDirectors']['name'];
$modelDirectors->position = $_POST['BoardOfDirectors']['position'];
}

but i am getting exception in this LOC : $thumbNew = Yii::app()->thumb;
The Exception is : CException
Property "CWebApplication.thumb" is not defined.
D:\xampp\htdocs\AlFerdousYII\protected\controllers\BoardOfDirectorsController.php(175): CModule->__get("thumb")
170 define('THUMBNAIL_IMAGE_MAX_WIDTH',160);
171 define('THUMBNAIL_IMAGE_MAX_HEIGHT',160);
172 $modelDirectors->image = CUploadedFile::getInstanceByName("image");
173 $modelDirectors->image->saveAs(UPLOADED_IMAGE_DESTINATION.$imagetime.CUploadedFile::getInstanceByName("image"));
174 $type=$modelDirectors->image->extensionName;
175 $thumbNew = Yii::app()->thumb;
176 $thumbNew->image = CUploadedFile::getInstanceByName("image");
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users