jcrop

hello all I’m trying this extension.

I wrote in the view that the controller is what the author said, but I have this error.


Undefined index: idOrAttributeName_x 

if i comment the controller, i see the image with the selection, than the image is found.

thanks

me too having the same issue , somebody please help

And I have this problem.

Anyone can help?

i have also same pblm anyone knows pls help me

[size=2]Hi,[/size]

You have to pass the attribute name. I hope this will solve your problem…

cheers





	/**

	 * Get the cropping coordinates from post.

	 * 

	 * @param type $attribute The model attribute name used.

	 * @return array Cropping coordinates indexed by : x, y, h, w

	 */

	public function getCoordsFromPost($attribute)

	{

		$coords = array('x' => null, 'y' => null, 'h' => null, 'w' => null);

		foreach ($coords as $key => $value) {

			$coords[$key] = $_POST[$attribute . '_' . $key];

		}

		return $coords;

	}



Thank u for ur reply chandran,I understand the syntax but if i gave my attribute name it throw the error undefined index:****

If u have any example in ur code or anything else pls show me…

Hi,

check this

View

https://github.com/sirinibin/yiidemos/blob/master/protected/views/site/ajaxcrop.php

Controller

https://github.com/sirinibin/yiidemos/blob/master/protected/controllers/SiteController.php

I hope this will help :)

Hi chandran,

if u don’t mind please check my code is it crt or not.

controller:

public function actionUpdate($id)

{


	$this->layout='//layouts/profilecontent';


	$model=$this->loadModel($id);


	$profilePic = 'shadow.png';


	


	if(isset($_POST['User']))


	{


		$model->attributes=$_POST['User'];


		$rnd = rand(0,9999);  // generate random number between 0-9999


    			$uploadedFile=CUploadedFile::getInstance($model,'profilepic');


	if($uploadedFile!=null) {


   			$fileName = "{$rnd}-{$uploadedFile}";  // random number + file name


    			$model->profilepic = $fileName;


	}


		$valid_format="jpg,png,jpeg,gif";


		if($model->save()&&$valid_format) {


			if(!empty($uploadedFile)) {


				$uploadedFile->saveAs(Yii::app()->basePath.'/../images/Editimage/'.$fileName); 


			Yii::import('ext.jcrop.EJCropper');


			$jcropper = new EJCropper();


			$jcropper->thumbPath = Yii::app()->basePath.'/../images/Editimage/'.$fileName;


			 


			// some settings ...


			$jcropper->jpeg_quality = 95;


			$jcropper->png_compression = 8;


			 


			// get the image cropping coordinates (or implement your own method)


			$coords = $jcropper->getCoordsFromPost('uploadPreview');


			 


			// returns the path of the cropped image, source must be an absolute path.


			$thumbnail = $jcropper->crop(Yii::app()->basePath.'/../images/thumbs/', $coords);	


			}


			 $this->redirect(array('view','id'=>$model->id));			


					


		}


		


				


	}





	$this->profileInfo = $this->renderPartial('profileInfo',array('model'=>$model),true);


	$this->render('update',array(


		'model'=>$model,


	));


}

view:

<?php

$this->widget(‘ext.jcrop.EJcrop’, array(

//


// Image URL


'url' =&gt; Yii::app()-&gt;baseUrl.'/images/Editimage/'.&#036;model-&gt;profilepic,


//


// ALT text for the image


'alt' =&gt; 'Crop This Image',


//


// options for the IMG element


'htmlOptions' =&gt; array('id' =&gt; 'uploadPreview','onclick'=&gt;&quot;return image();&quot;),


//


// Jcrop options (see Jcrop documentation)


'options' =&gt; array(


	'minSize' =&gt; array(50, 50),


	'aspectRatio' =&gt; 1,


	'onRelease' =&gt; &quot;js:function() {ejcrop_cancelCrop(this);}&quot;,


),


// if this array is empty, buttons will not be added


'buttons' =&gt; array(


	'start' =&gt; array(


    	'label' =&gt; Yii::t('promoter', 'Adjust thumbnail cropping'),


    	'htmlOptions' =&gt; array(


        	'class' =&gt; 'myClass',


        	'style' =&gt; 'color:red;', // make sure style ends with « ; »


    	)


	),


	'crop' =&gt; array(


    	'label' =&gt; Yii::t('promoter', 'Apply cropping'),


	),


	'cancel' =&gt; array(


    	'label' =&gt; Yii::t('promoter', 'Cancel cropping')


	)


),


// URL to send request to (unused if no buttons)


'ajaxUrl' =&gt; Yii::app()-&gt;createAbsoluteUrl('user/update&amp;id='.(&#036;model-&gt;id)),


//


// Additional parameters to send to the AJAX call (unused if no buttons)


'ajaxParams' =&gt; array('someParam' =&gt; 'someValue'),

));

?>

[size=2]Hi shobana,[/size]

[size=2]

[/size]

Your code looks fine. But i cannot comment on your code without knowing outcome …

what is the result with above code ?

ithe image display with cropping option but the cropped image can’t save in thumbs folder

Hi

please can you check in your code… whether code reaches after this if condition :(

I dont think it reaches this level :)

[color="#1C2837"][size="2"]$valid_format="jpg,png,jpeg,gif";[/size][/color]

[color="#1C2837"][size="2"]if($model->save()&&$valid_format) {[/size][/color]

The original image save in the editimage folder under the if condition but the cropped image does not saved…

Hi,

Have you tried printing this value…

[color=#1C2837][size=2]$thumbnail[/size][/color]

[color=#1C2837][size=2]what is the name… are you getting?[/size][/color]

This link also not working chandran…I downloaded that file and implemented using same file…this is also not save cropped image folder

the printing value is: bool(false); now wat i have to do

Hi,

Dont worry

Goto this file EJCropper.php

Goto crop method. that is the method responsible for saving

there you have try print_r($src)

print_r($thumbname)

then there is so many if else… just try debugging those code…

i am sure u will get output today… cheers :)

thank you chandran…

How to debug the code… please tell me

Reply has been delivered to your question… please check mail