petehouston/laravel-tinymce-simple-imageupload
Composer 安装命令:
composer require petehouston/laravel-tinymce-simple-imageupload
包简介
Simple image upload for TinyMCE in Laravel.
README 文档
README
The simple image upload for TinyMCE in Laravel.
Why made this?
Because, I use TinyMCE and basically, it is pretty hard to understand how to upload images directly to the editor while editing content. There are many TinyMCE image uploaders out there, but they are too complicated in functions, and I only need one core use-case, pick up an image to upload.
That's it, so I create this package for my projects to re-use. Well, if you want, you can use this too.
This package works with Laravel 5.0+.
Installation
For Laravel 5.5+:
$ composer require "petehouston/laravel-tinymce-simple-imageupload:~1.3"
For Laravel before 5.5:
$ composer require "petehouston/laravel-tinymce-simple-imageupload:~1.1"
For laravel version 5.4 and older, you need to register the service provider in config/app.php.
'providers' => [
...
Petehouston\Tinymce\TinymceServiceProvider::class,
]
Usage
In the view that contain setup for TinyMCE, you need to include the upload view, add this line at the bottom,
@include('mceImageUpload::upload_form')
Don't worry, this form is hidden from your view, no-one will see it because it is display: none.
Next step is to add this config to the tinymce object,
tinymce.init({
// .. your config here
relative_urls: false,
file_browser_callback: function(field_name, url, type, win) {
// trigger file upload form
if (type == 'image') $('#formUpload input').click();
}
});
That's all, now you should be able to upload image directly to the editor while writing content.
You can publish view in case you need to customize in resources/views directory
$ php artisan vendor:publish --provider=Petehouston\Tinymce\TinymceServiceProvider
Try example
There is a setup example in the package, you can try in your project by adding a sample route,
Route::get('/tinymce_example', function () {
return view('mceImageUpload::example');
});
Some notes
The image upload handler
I setup already a controller Petehouston\Tinymce\TinymceController which implements a method for image uploading.
As you can see it will store all uploaded images in public/img directory, the name is like a concatenated hash,
$filename = 'image_'.time().'_'.$image->hashName();
The default route for handling image upload is /tinymce/simple-image-upload.
Customize upload url and controller
If you don't want to pre-config of the package, make yours.
While including the uploading form, pass in the url of handling post image upload
@include('mceImageUpload::upload_form', ['upload_url' => 'YOUR_URL_FOR_HANDLING_IMAGE_UPLOAD'])
Add a method for handling image upload that should return the same result as in Petehouston\Tinymce\TinymceController.
petehouston/laravel-tinymce-simple-imageupload 适用场景与选型建议
petehouston/laravel-tinymce-simple-imageupload 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 50.36k 次下载、GitHub Stars 达 67, 最近一次更新时间为 2016 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「tinymce」 「laravel」 「Image upload」 「laravel 5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 petehouston/laravel-tinymce-simple-imageupload 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 petehouston/laravel-tinymce-simple-imageupload 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 petehouston/laravel-tinymce-simple-imageupload 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Adds links to data objects in TinyMCE editor
TinyMCE Silverstripe 4 inspired theme
A Laravel Package to integrate elFinder 2
A Laravel Nova field that provides integration of TinyMCE.
Alfabank REST API integration
统计信息
- 总下载量: 50.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 68
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-26