Comments (11)
The 'icon-framework' option has not been setup in Yii params. Check your configuration file.
from yii2-widget-cropbox.
What version of cropbox? And could you give me your code?
from yii2-widget-cropbox.
3.0
from yii2-widget-cropbox.
view:
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($model, 'image')->widget(Cropbox::className(), [
'attributeCropInfo' => 'crop_info',
]); ?>
<?= $form->field($model, 'order')->textInput() ?>
<?= $form->field($model, 'en_groupname')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
from yii2-widget-cropbox.
model:
100], [['imageFile'], 'string', 'max' => 255], [ 'image', 'image', 'extensions' => ['jpg', 'jpeg', 'png', 'gif'], 'mimeTypes' => ['image/jpeg', 'image/pjpeg', 'image/png', 'image/gif'], ], ['crop_info', 'safe'], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'projgroup_id' => Yii::t('app', 'Projgroup ID'), 'ar_groupname' => Yii::t('app', 'Arabic Groupname'), 'en_groupname' => Yii::t('app', 'English Groupname'), 'imageFile' => Yii::t('app', 'Image File'), 'image' => Yii::t('app', 'Groupimg'), 'created' => Yii::t('app', 'Created'), 'createdby' => Yii::t('app', 'Createdby'), 'modified' => Yii::t('app', 'Modified'), 'modifiedby' => Yii::t('app', 'Modifiedby'), 'order' => Yii::t('app', 'Order'), ]; } /** * @return \yii\db\ActiveQuery */ public function getProjects() { return $this->hasMany(Projects::className(), ['projgroup_id' => 'projgroup_id']); } public function afterSave($insert, $changedAttributes) { // open image $image = Image::getImagine()->open($this->image->tempName); // rendering information about crop of ONE option $cropInfo = Json::decode($this->crop_info)[0]; $cropInfo['dWidth'] = (int)$cropInfo['dWidth']; //new width image $cropInfo['dHeight'] = (int)$cropInfo['dHeight']; //new height image $cropInfo['x'] = $cropInfo['x']; //begin position of frame crop by X $cropInfo['y'] = $cropInfo['y']; //begin position of frame crop by Y // Properties bolow we don't use in this example //$cropInfo['ratio'] = $cropInfo['ratio'] == 0 ? 1.0 : (float)$cropInfo['ratio']; //ratio image. //$cropInfo['width'] = (int)$cropInfo['width']; //width of cropped image //$cropInfo['height'] = (int)$cropInfo['height']; //height of cropped image //$cropInfo['sWidth'] = (int)$cropInfo['sWidth']; //width of source image //$cropInfo['sHeight'] = (int)$cropInfo['sHeight']; //height of source image //delete old images $oldImages = FileHelper::findFiles(Yii::getAlias('@path/to/save/image'), [ 'only' => [ $this->id . '.*', 'thumb_' . $this->id . '.*', ], ]); for ($i = 0; $i != count($oldImages); $i++) { @Unlink($oldImages[$i]); } //saving thumbnail $newSizeThumb = new Box($cropInfo['dWidth'], $cropInfo['dHeight']); $cropSizeThumb = new Box(200, 200); //frame size of crop $cropPointThumb = new Point($cropInfo['x'], $cropInfo['y']); $pathThumbImage = Yii::getAlias('@path/to/save/image') . '/thumb_' . $this->id . '.' . $this->image->getExtension(); $image->resize($newSizeThumb) ->crop($cropPointThumb, $cropSizeThumb) ->save($pathThumbImage, ['quality' => 100]); //saving original $this->image->saveAs( Yii::getAlias('@path/to/save/image') . '/' . $this->id . '.' . $this->image->getExtension() ); } }from yii2-widget-cropbox.
controller:
public function actionCreate()
{
$model = new Projectsgroups();
//$upload = new UploadForm();
if ($model->load(Yii::$app->request->post()))
{
// get uploaded file information
$groupName = strtolower($model->en_groupname);
$imageName = str_replace(' ', '',$groupName );;
$model->image = UploadedFile::getInstance($model, 'image');
$model->image->saveAs('../../frontend/web/images/project/' . $imageName.'.'.$model->image->extension);
// save the path in DB
$model->imageFile = $imageName.'.'.$model->image->extension;
$model->created = date('Y-m-d h:m:s');
$model->save();
return $this->redirect(['view', 'id' => $model->projgroup_id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
from yii2-widget-cropbox.
Wow, very dirty... You should wrap you code in markdown code tag, please.
Could you give me screenshot of the error message?
from yii2-widget-cropbox.
from yii2-widget-cropbox.
It's a bug. You can fix it following code or use 4 version of cropbox:
<?= $form->field($model, 'image')->widget(Cropbox::className(), [
'attributeCropInfo' => 'crop_info',
'optionsCropbox' => [
'cropSettings' => [],
],
]); ?>
from yii2-widget-cropbox.
https://github.com/kartik-v/yii2-icons#global-setup
from yii2-widget-cropbox.
its work you the man 💯
from yii2-widget-cropbox.
Related Issues (20)
- How to save upload filename into database ? HOT 4
- Undefined index (dh/ dHeight/ dheight, x, y) HOT 2
- Crop square image HOT 4
- File does not exist. HOT 1
- Events HOT 3
- Load the original image in cropbox HOT 1
- add another button HOT 1
- Как использовать ratio? HOT 1
- How to save the cropped picture for beginner? HOT 4
- Replace jquery-cropbox to js-cropbox
- Basic tests coverage
- Minified resourse files
- Undefined index: dHeight HOT 12
- error while submitting form with this widget HOT 1
- How to make the plugin work with mobile devices? (For Panning and zooming) HOT 3
- should I create the attribute for crop_info in my table? HOT 2
- Class 'bupy7\cropbox\Cropbox' not found
- anddusik
- Please, add support for custom callbacks from widget HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-widget-cropbox.