Yii2.0 integrated elfinder image manager call method

Source: Internet
Author: User
Although the tutorial is Russian, don't worry, just follow the code on the line steps: 1, use composer to install extension composerrequire -- prefer-distmihaildevyii2-elfinder & quot; * & quot; Yii2 extension: https://github.com/MihailDev/yii2-elfinder
Although the tutorial is in Russian, don't worry, just do it by code.
Steps:
1. use composer to install extensions
Composer require -- prefer-dist mihaildev/yii2-elfinder "*"

2. Add configuration information. I am a Yii2 advanced template and used in the background. open the backend/config/main. php configuration file.
Added at the same level as 'components'

'Controllermap' => ['elfinder '=> ['class' => 'mihaildev \ elfinder \ pathcontroller', 'access' => [' @ '], 'root' => ['path' => 'uploads', // main directory path 'name' => 'Files'], /* 'watermark' => ['source' => _ DIR __. '/logo.png', // Path to Water mark image' marginRight '=> 5, // Margin right pixel 'marginbottom' => 5, // Margin bottom pixel 'quality' => 95, // JPEG image save quality 'transparency '=> 70, // Water mark image transparency (other than PNG) 'targettype' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats (bit-field) 'targetminpixel' => 200 // Target image minimum pixel size] */],

3. add default parameters
Open commmon (backend)/config/params. php

// Elfinder default configuration 'elfinderultconfig' => ['language' => 'zh _ cn', 'controller' => 'elfinder ', // Default control name 'filter' => 'image', // only manage picture https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes 'template' =>'

{Input} {button}

', 'Options' => ['class' => 'form-control'], 'buttonoptions' => ['class' => 'btn btn-default'], 'buttonname' => 'browsed '],

4. introduce the call in the last step.

Open the form view file to be used and add the following code:

Use mihaildev \ elfinder \ InputFile;
 Params ['elfinderultconfig'], ['path' => $ dir]); echo $ form-> field ($ model, 'carlogo ')-> widget (InputFile :: className (), $ elfinderConfig);?>

Final effect:

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.