'attribute' => 'image', 'file'
'class' => '\yiidreamteam\upload\FileUploadBehavior',
'attribute' => 'fileUpload',
'filePath' => '@webroot/uploads/[[pk]].[[extension]]',
'fileUrl' => '/uploads/[[pk]].[[extension]]',
public function behaviors()
{
return [
'status' => [
'class' => StatusBehavior::className(),
'status_value' => $this->status_id,
'statusList' => Yii::$app->modules['article']->status_list,
],
'image' => [
'class' => ImageUploadBehavior::className(),
'attribute' => 'image',
'random_name' => 'true',
'image_path' => Yii::$app->modules['article']->imagePath,
'image_url' => Yii::$app->modules['article']->imageUrl,
'size_for_resize' => [
[640,480,true],
[640,null,false],
[50,50,true]
]
],
'timestamp' => [
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'date_create',
'updatedAtAttribute' => false,
],
'seo' => [
'class' => \wokster\seomodule\SeoBehavior::className(),
],
'tags' => [
'class' => TagsBehavior::className(),
],
];
}
'attribute' => 'image',
'class' => ImageUploadBehavior::className(),
'attribute' => 'image',
Yii2-images is yii2 module that allows to attach images to any of your models, next you can get images in any sizes, also you can set main image of images set.т.е этот модуль не занимается загрузкой изображений- он делает привязку любой модели к уже загруженным изображениям с последующим выводом нужных размеров, и возможностью установки основного изображения. Попробую установить mohorev/yii2-upload-behavior надеюсь, он может загружать фото для статей?)
'class' => 'rico\yii2images\behaviors\ImageBehave',
'attribute' => 'image',
'random_name' => 'true',
'image_path' => Yii::$app->modules['article']->imagePath,
'image_url' => Yii::$app->modules['article']->imageUrl,
'size_for_resize' => [
[640,480,true],
[640,null,false],
[50,50,true]
]
<?php
use yii\helpers\Html;
use kartik\form\ActiveForm;
use \dosamigos\fileinput\FileInput;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model wokster\article\models\Article */
/* @var $form yii\widgets\ActiveForm */
/* @var $model app\modules\admin\models\Gallery */
if($model->hasErrors()):
\wokster\ltewidgets\BoxWidget::begin([
'solid'=>true,
'color'=>'danger',
'title'=>'Ошибки валидации',
'close'=> true,
]);
$error_data = $model->firstErrors;
echo \yii\widgets\DetailView::widget([
'model'=>$error_data,
'attributes'=>array_keys($error_data)
]);
\wokster\ltewidgets\BoxWidget::end();
endif;
?>
<div class="-article-form">
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'image')->fileInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<div class="article-form">
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data'],
'enableClientValidation' => false
]); ?>
<?= $form->field($model, 'title', ['addon' => ['prepend' => ['content' => '<i class="fa fa-pencil"></i>']],'options'=>['class'=>'col-xs-12 col-md-6']])->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'url', ['addon' => ['prepend' => ['content' => '<i class="fa fa-globe"></i>']],'options'=>['class'=>'col-xs-12 col-md-6']])->widget(\wokster\behaviors\TranslitWidget::className())
?>
<?= $form->field($model, 'text',['options'=>['class'=>'col-xs-12']])->widget(\vova07\imperavi\Widget::className(),[
'settings' => [
'lang' => 'ru',
'minHeight' => 200,
'pastePlainText' => true,
'imageUpload' => \yii\helpers\Url::toRoute(['/article/article/image-upload']),
'imageManagerJson' => \yii\helpers\Url::toRoute(['/article/article/images-get']),
/*'imageUpload' => \yii\helpers\Url::to (['/site/save-redactor-img']),*/
'replaceDivs' => false,
'formattingAdd' => [
[
'tag' => 'p',
'title' => 'text-success',
'class' => 'text-success'
],
[
'tag' => 'p',
'title' => 'text-danger',
'class' => 'text-danger'
],
],
'plugins' => [
'fullscreen',
'table',
'imagemanager',
'fontcolor',
'fontsize',
'video'
]
]
])
?>
<div class="row">
<div class="col-xs-8">
<?= $form->field($model, 'status_id',['options'=>['class'=>'col-xs-12']])->dropDownList(Yii::$app->modules['article']->status_list)
?>
<?= $form->field($model, 'type_id', ['addon' => ['prepend' => ['content' => '<i class="fa fa-pencil"></i>']],'options'=>['class'=>'col-xs-12']])->dropDownList(Yii::$app->modules['article']->type_list) ?>
<div class="<?= ($model->type_id == \wokster\article\Article::TYPE_PAGE)?' hidden':''?>" id="start-date-div">
<?= $form->field($model, 'date_start', ['options'=>['class'=>'col-xs-12']])->widget(\kartik\datecontrol\DateControl::className(),[]) ?>
</div>
<div class="<?= ($model->type_id == \wokster\article\Article::TYPE_SALE)?'':' hidden'?>" id="sale-date-div">
<?= $form->field($model, 'date_finish', ['options'=>['class'=>'col-xs-12']])->widget(\kartik\datecontrol\DateControl::className(),[]) ?>
</div>
<?= $form->field($model, 'new_tags', ['addon' => ['prepend' => ['content' => '<i class="fa fa-pencil"></i>']],'options'=>['class'=>'col-xs-12']])->widget(\wokster\tags\TagsInputWidget::className()) ?>
</div>
<div class="col-xs-4">
<?= $form->field($model, 'file', ['options'=>['class'=>'col-xs-12']])->label(false)->widget(FileInput::className(),[
'attribute' => 'image', // image is the attribute
// using STYLE_IMAGE allows me to display an image. Cool to display previously
// uploaded images
'thumbnail' => '<img src="'.$model->getImage().'" />',
'style' => FileInput::STYLE_IMAGE
]);?>
</div>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?=$form->field($model, 'image')->fileInput() ?>
</div>
<?= \wokster\seomodule\SeoFormWidget::widget(['model'=>$model,'form'=>$form]);?>
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' =>'btn btn-success']) ?>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php $this->registerJs("
$('#article-type_id').on('change',function(){
var type = $(this).val();
if(type == ".\wokster\article\Article::TYPE_SALE."){
$('#sale-date-div').removeClass('hidden');
$('#start-date-div').removeClass('hidden');
}else if(type == ".\wokster\article\Article::TYPE_NEWS."){
$('#sale-date-div').addClass('hidden');
$('#start-date-div').removeClass('hidden');
}else{
$('#sale-date-div').addClass('hidden');
$('#start-date-div').addClass('hidden');
}
});
");
<?php
use \kartik\datecontrol\Module;
return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'modules'=>[
'yii2images' => [
'class' => 'rico\yii2images\Module',
//be sure, that permissions ok
//if you cant avoid permission errors you have to create "images" folder in web root manually and set 777 permissions
'imagesStorePath' => 'images/store', //path to origin images
'imagesCachePath' => 'images/cache', //path to resized copies
'graphicsLibrary' => 'GD', //but really its better to use 'Imagick'
'placeHolderPath' => '@webroot/images/placeHolder.png', // if you want to get placeholder when image not exists, string will be processed by Yii::getAlias
],
'datecontrol' => [
'class' => 'kartik\datecontrol\Module',
// format settings for displaying each date attribute (ICU format example)
'displaySettings' => [
Module::FORMAT_DATE => 'yyyy-M-dd',
Module::FORMAT_TIME => 'php: H:i',
Module::FORMAT_DATETIME => 'php:d M Y H:i',
],
// format settings for saving each date attribute (PHP format example)
'saveSettings' => [
Module::FORMAT_DATE => 'php:U',
Module::FORMAT_TIME => 'php:U',
Module::FORMAT_DATETIME => 'php:U',
],
// set your display timezone
'displayTimezone' => 'europe/moscow',
// set your timezone for date saved to db
'saveTimezone' => 'UTC',
// automatically use kartik\widgets for each of the above formats
'autoWidget' => true,
]
],
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'settings' => [
'class' => 'wokster\settings\components\Settings',
],
'image' => [
'class' => 'yii\image\ImageDriver',
'driver' => 'GD', //GD or Imagick
],
'i18n' => [
'translations' => [
'file-input' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => 'dosamigos\fileinput\src\messages',
],
],
],
],
];
<?php
/* @var $this yii\web\View */
/* @var $blog medeyacom\Blog */
/* @throws NotFoundHttpException if the model cannot be found
*/
use yii\helpers\Html;
use yii\widgets\Breadcrumbs;
use metalguardian\fotorama;
use yii\web\MethodNotAllowedHttpException;
use yii\web\NotFoundHttpException;
use yii\helpers\VarDumper;
$this->title = $blog->title;
/*$desc = \yii\helpers\StringHelper::truncateWords(strip_tags($blog->body),20, '');*/
$this->registerMetaTag(['property'=>'og:title','content'=>$this->title]);
$this->registerMetaTag(['name'=>'description','content'=>$desc]);
$this->registerMetaTag(['property'=>'og:description','content'=>$desc]);
$this->registerMetaTag(['property'=>'og:site_name','content'=>$this->title]);
$this->params['breadcrumbs'] = [
['label'=>'публикации','url'=>['blog/index']],
['label'=>$blog->title]
];
?>
<h1><?=$blog->title?></h1>
<?=$blog->text?>
<div class="blog-view">
<?php
$fotorama = \metalguardian\fotorama\Fotorama::begin(
[
'options' => [
'loop' => true,
'hash' => true,
'ratio' => 800/600,
],
'spinner' => [
'lines' => 20,
],
'tagName' => 'span',
'useHtmlData' => false,
'htmlOptions' => [
'class' => 'custom-class',
'id' => 'custom-id',
],
]
);
VarDumper:: dump($model);
print_r($model);
exit();
foreach ($model->images as $one) {
echo Html::img($one->imageUrl,['alt'=>$one->alt]);
}
$fotorama->end(); ?>
</div>
echo Html::img($one->imageUrl,['alt'=>$one->alt]);
}
Yii не может найти файл в папке vendor, там хранятся зависимости.
composer install --no-scripts
Во-вторых, папка vendor не заливается на сервер (и вообще должна игнорироваться в VCS).
Третье – используйте систему контроля версий (git), файлы по FTP заливать – моветон.
Судя по вопросу, в разработке Вы новичок, изучите устройство и варианты использования систем контроля версий, системы миграций БД.
Но появилась ошибка: Class 'vova07\imperavi\actions\GetAction' not found
ArticleController