Laravel-admin Integrated ueditor editor Picture List display Problem solving method

Source: Internet
Author: User
This article mainly introduces the Laravel-admin Integrated ueditor editor Picture List display problem solving method, has a certain reference value, now share to everyone, have the need of friends can refer to

The Laravel-admin integrated Ueditor recommends the use of Laravel-u-editor, which is the Laravel composer version of Ueditor. Based on Ueditor 1.4.3.3 development, supports EN, ZH_CN, ZH_TW, and supports local and seven cow cloud storage, default to local upload public/uploads

Installation

Composer require Stevenyangecho/laravel-u-editor then add a line providers under config/app.php stevenyangecho\ueditor\ Ueditorserviceprovider::class Execute PHP Artisan vendor:publish

Basic Configuration

1. Add component files: App/admin/extensions/form/ueditor.php:<?phpnamespace app\admin\extensions\form;use Encore\Admin\Form \field;/** * Baidu Editor * Class Ueditor * @package app\admin\extensions\form */class Ueditor extends field{//define View Prote    CTED $view = ' admin.ueditor ';    CSS resource protected static $CSS = []; JS resource protected static $JS = [' laravel-u-editor/ueditor.config.js ', ' laravel-u-editor/ueditor.all.min.    JS ', ' laravel-u-editor/lang/zh-cn/zh-cn.js '];        Public function render () {$cs =csrf_token ();        $this->script = &LT;&LT;&LT;EOT//Solve the problem of the second entry loading does not come out ue.deleditor ("Ueditor");         The default ID is ueditor var UE = ue.geteditor (' Ueditor ');        Ue.ready (function () {Ue.execcommand (' serverparam ', ' _token ', ' $cs '); });        EOT;    return Parent::render (); }}2. Add view file: Resources/views/admin/ueditor.blade.php<p class= "Form-group {!!! $errors->has ($errorKey)?: ' Has-error '!} ' > <label for= "{{$id}} "class=" Col-sm-2 control-label ">{{$label}}</label> <p class=" col-sm-8 "> @include (' admin:: Form.error ') {--this style can limit his height and will not grow with the content-}} <textarea type= ' Text/plain ' style= ' height:400px; id= ' ued  Itor ' id= ' {{$id}} ' Name= ' {{$name}} ' placeholder= ' {{$placeholder}} ' {!! $attributes!}        class= ' Ueditor ' > {!! old ($column, $value)!!} </textarea> @include (' Admin::form.help-block ') </p></p>3. Then register into Laravel-admin and add the following code to the app/admin/bootstrap.php: use App\admin\extensions\form\ueditor; Encore\admin\form::extend (' Ueditor ', Ueditor::class); 4. Call: $form->ueditor (' content ', ' contents ')->rules (' Required ');

Configure Seven cattle Service

Open file config\ueditorupload.php configuration seven kn configuration parameter//will next line comment//        ' mode ' = ' local ',//upload method, local   Qiniu for seven kn        ' mode ' = > ' Qiniu ',//upload method, local   Qiniu for seven cattle        //Seven cows, if mode= ' Qiniu ', the following is required.        ' Qiniu ' =>[            ' accessKey ' = ' ... ',            ' secretkey ' = ' ... ',            ' bucket ' = ' ... ',            ' url ' = ' ... ',//seven KN assigned CDN domain name, note with HTTP//        ]    ],

Fixed an issue where the file list could not be managed in the upload interface

Vendor\stevenyangecho\laravel-u-editor\src\listsqiniu.phppublic function GetList () {$size = $this->request-&        Gt;get (' size ', $this->listsize);        $start = $this->request->get (' Start ', ');        $auth = new Auth (config (' UEditorUpload.core.qiniu.accessKey '), config (' UEditorUpload.core.qiniu.secretKey '));        $bucketManager = new Bucketmanager ($auth); Comment out the following line//list ($items, $marker, $error) = $bucketManager->listfiles (config (' UEditorUpload.core.qiniu.bucket ') , $this->path, $start, $size);//The following three lines are modified $result 1 = $bucketManager->listfiles (config (' UEditorUpload.core.qin        Iu.bucket '), $this->path, $start, $size);        $size = count ($result 1);                If you do not get the items, the report cannot find the key error $items = $result 1[0][' items '];//determine if the error if ($size > 2) {return [                "state" = = $error->message (), "list" = = Array (), "Start" = $start,          "Total" = 0  ]; if (empty ($items)) {return ["state" = "no match file", "list" =        Array (), "Start" = $start, "Total" and 0];        } $files =[];//dd ($items [' Items ']); foreach ($items as $v) {if (Preg_match ("/\. (". $this->allowfiles. ") $/i", $v [' key ']) {$files [] = array (' URL ' =>rtrim (' UEditorUpload.core.qini U.url '), '/'). '            /'. $v [' key '], ' mtime ' and ' = $v [' MimeType '],); }} if (Empty ($files)) {return ["state" = "no match file", "Lis        T "= = Array ()," start "= = $start," Total "and 0]; }/* Returns data */$result = ["state" = "SUCCESS", "list" = $files, "STA RT "= $start," Total "and" total "= Count($files)];    return $result; }

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.