https://github.com/dmstr/yii2-filemanager-ck-browser
use dmstr/yii2-filemanager-widgets as filebrowser from within ck-editor
https://github.com/dmstr/yii2-filemanager-ck-browser
Last synced: 9 months ago
JSON representation
use dmstr/yii2-filemanager-widgets as filebrowser from within ck-editor
- Host: GitHub
- URL: https://github.com/dmstr/yii2-filemanager-ck-browser
- Owner: dmstr
- Created: 2022-08-24T08:41:00.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-24T08:44:08.000Z (almost 4 years ago)
- Last Synced: 2025-06-12T17:11:23.938Z (12 months ago)
- Language: PHP
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yii2-filemanager-ck-browser
This yii2 module provide a ck editor plugin for getting [dmstr/yii2-filemanager-widgets](https://github.com/dmstr/yii2-filemanager-widgets/) as filebrowser in ckeditor.
[ckeditor filebrowser docs](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_file_browser_api.html)
The main ideas behind this module is:
- if we have a [filefly module](https://github.com/dmstr/yii2-filefly-module) we should be able to use [filemanagerWidget](https://github.com/dmstr/yii2-filemanager-widgets/) as fileBrowser from within ckeditor instances
- for this we need:
- an url (controller/action) that could be used as filebrowser URL
- a filemanagerWidget (with custom options) which will be displayed when this url is called
- a JS callback that can be triggered for one item (image or file) from within filemanager
- configurable JS snippets to be able to define which item property should be used as URL
required config examples to enable an existing filemanager via this module as filebrowser plugin in ckEditor
## yii config
enable the filefly module
```php
'modules' => [
# ....
'filefly' => [
'filesystemComponents' => [
'ftp' => 'fsFtp',
],
// define correct image and file(download) urls for images and files for your use cases
'urlCallback' => function($item) {
$urls = [];
$isImageFileExtList = ['jpg', 'jpeg', 'gif', 'tiff', 'tif', 'png', 'bmp'] ;
if ($item['type'] === 'file') {
if (in_array(strtolower($item['extension']), $isImageFileExtList)) {
$urls['image small'] = FrontendHelper::getFileFlyPath($item['path'], ImagePresets::MEDIA_CONTENT_S);
$urls['image content'] = FrontendHelper::getFileFlyPath($item['path'], ImagePresets::MEDIA_CONTENT);
$urls['image big'] = FrontendHelper::getFileFlyPath($item['path'], ImagePresets::MEDIA_CONTENT_BIG);
}
else {
$urls['download'] = FrontendHelper::getFileFlyPath($item['path'], ImagePresets::MEDIA_RAW);
}
}
return $urls;
}
],
],
```
enable the yii2-filemanager-ck-browser module
```php
'modules' => [
# ....
'filefly-ck-browser' => [
'class' => \dmstr\filemanagerCkBrowser\Module::class,
'fileflyHandlerUrl' => '/filefly/api',
// angular filemanager item prop where the urls should be picked from
// see: \dmstr\filemanagerCkBrowser\controllers\BrowserController::initCkBrowserVars()
'filemanagerCkBrowserItemImageUrl' => 'item.model.urls["image content"]',
'filemanagerCkBrowserItemFileUrl' => 'item.model.urls["download"]'
]
# ....
],
```
## ckeditor.config
```
"extraPlugins": "....,filebrowser",
"filebrowserImageBrowseUrl": "/filefly-ck-browser/browser/image",
"filebrowserBrowseUrl": "/filefly-ck-browser/browser/file",
```
for more config options, see [ckeditor filebrowser docs](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_file_browser_api.html)
## permissions
according to the