Requirements ¶
- Twitter Bootstrap
- Yii 1.1 above
Screenshots ¶
Usage ¶
Just call the widget with your spesific params the params are:
/**
* Using upload file
* if true, XPhoto will enable file upload from computer harddrive
*/
public $upload = true;
/**
* Using capture
* if true, XPhoto capture from your webcam or camera which attached on your computer
*/
public $capture = true;
//public $allowedExtensions = array('jpg','jpeg','png');
public $url;
/**
* model name for active field
*/
public $model;
/**
* attribut of model
*/
public $attribute;
/**
* width of photo canvas : in pixel
*/
public $width = 300;
/**
* height of photo canvas : in pixel
*/
public $height = 350;
/**
* ID of canvas element
*/
public $canvasID = 'xphoto-canvas';
/**
* ID of video element
*/
public $videoID = 'xphoto-video';
/**
* ID of photo element
*/
public $photoID = 'xphoto-photo';
/**
* Modal dialog for capture photo
* if modal is true, when capturing photo the modal will shown as capture media container
*/
public $withModal = true;
public $cssFile;
public $htmlOptions = array();
Call on your view: ¶
$this->widget('ext.xphoto.XPhoto',array(
'model'=>$model,
'attribute'=>'user_photo',
));
On your controller action: ¶
if (!empty($_POST['Profile']['user_photo']))
{
$foto = $_POST['Profile']['user_photo'];
//Decode with base64
$foto = str_replace('data:image/png;base64,', '', $foto);
$foto = str_replace(' ', '+', $foto);
$data_foto = base64_decode($foto);
//Set photo filename
$filename = Yii::app()->user->name.'.png';
$filepath = YiiBase::getPathOfAlias("webroot").'/uploads/userphotos/'.$filename;
$writeToDisk = file_put_contents($filepath, $data_foto);
}
Resources ¶
- XPhoto Project page on Github
- There is not yet demo
Image format and size
hello, Great extension but I would like to know if :
it allows cropping selected picture
it supports other format than png because in the example above you put png.
A part from that how can I limit the format(to images format only) and the file size?
I don't undestand the usage of $_POST['profile']['user_photo'].I Have user model for which I want to use your extension(user profile photo) and I have a model that must be linked to many photos. Any idea on how I can apply the extension
Thanks!!!
how i use this extension in yii 2?
Thanks before :)
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.