V
V
Vladislav Sofienko2017-09-06 08:40:41
Yii
Vladislav Sofienko, 2017-09-06 08:40:41

How to add imagemanager to vova07/yii2-imperavi-widget?

I added the imagemanager line to plugins[] and added it to the action, but there is still no image button. I did everything as it says in the documentation .
_form.php

<?
    echo $form->field($model, 'body')->widget(Widget::className(), [
        'settings' => [
            'lang' => 'ru',
            'toolbar' => true,
            'minHeight' => 200,
            'imageManagerJson' => Url::to(['/default/images-get']),
            'plugins' => [
                'table',
                'fontsize',
                'fontcolor',
                'fontfamily',
                'imagemanager',
                'fullscreen',
            ]
        ]
    ]);
?>

PageController.php
public function actionCreate()
{
        $model = new Page();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('create', [
                'model' => $model,
                'images-get' => [
                    'class' => 'vova07\imperavi\actions\GetAction',
                    'url' => Yii::$app->getRequest()->getHostInfo() . '/upload/images/', // URL адрес папки где хранятся изображения.
                    'type' => GetAction::TYPE_IMAGES,
                ]
            ]);
        }
 }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-09-06
@webinar

I did everything as it says in the documentation.

not everything, except for the url, you need to specify the path, how do you think it will collect pictures by url?
'images-get' => [
                    'class' => 'vova07\imperavi\actions\GetAction',
                    'url' => Yii::$app->getRequest()->getHostInfo() . '/upload/images/', 
                   'path' => '@upload/images',
                    'type' => GetAction::TYPE_IMAGES,
                ]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question