PHP code example of bestyii / yii2-ueditor-plus
1. Go to this page and download the library: Download bestyii/yii2-ueditor-plus library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bestyii / yii2-ueditor-plus example snippets
public function actions()
{
return [
'UeUpload' => [
'class' => 'bestyii\ueditor\plus\UEditorPlusUpload',
// 可选参数, 参考 config.php
'config' => [
'imageMaxSize' => 1*1024*1024,
'imageAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'],
'imagePathFormat' => '/uploads/image/{yyyy}{mm}/{yy}{mm}{dd}_{hh}{ii}{ss}_{rand:4}',
'thumbStatus' => false,
'thumbWidth' => 300,
'thumbHeight' => 200,
'thumbMode' => 'outbound',
],
],
];
}
// 1. 简单调用(基于模型):
$form->field($model, 'content')->widget('bestyii\ueditor\plus\UEditorPlus');
// 2. 带参数调用(此模式下仅`$editorOptions`参数可用):
$form->field($model, 'content')->widget('bestyii\ueditor\plus\UEditorPlus',[
'editorOptions' => [
'initialFrameWidth' => 1000,
'initialFrameHeight' => 500,
],
]);
// 3. 不带`$model`调用(已列出所有可用参数, 可适当忽略):
\bestyii\ueditor\plus\UEditorPlus::widget([
'id' => 'editor',
'attribute' => 'content',
//'name' => 'content',
'value' => '初始化编辑器时的内容',
'editorOptions' => [
'initialFrameWidth' => 1000,
'initialFrameHeight' => 500,
],
]);