All Projects → petehouston → Laravel Tinymce Simple Imageupload

petehouston / Laravel Tinymce Simple Imageupload

Simple image upload for TinyMCE in Laravel.

Projects that are alternatives of or similar to Laravel Tinymce Simple Imageupload

Laravel Blade X
Use custom HTML components in your Blade views
Stars: ✭ 538 (+715.15%)
Mutual labels:  laravel, blade
Blade Ui Kit
A set of renderless components to utilise in your Laravel Blade views.
Stars: ✭ 763 (+1056.06%)
Mutual labels:  laravel, blade
Idea Php Laravel Plugin
Laravel Framework Plugin for PhpStorm / IntelliJ IDEA
Stars: ✭ 537 (+713.64%)
Mutual labels:  laravel, blade
Coreui Free Laravel Admin Template
CoreUI Free Laravel Bootstrap Admin Template
Stars: ✭ 353 (+434.85%)
Mutual labels:  laravel, blade
Blade Zondicons
A package to easily make use of Zondicons in your Laravel Blade views.
Stars: ✭ 40 (-39.39%)
Mutual labels:  laravel, blade
Comments
Native comments for your Laravel application.
Stars: ✭ 390 (+490.91%)
Mutual labels:  laravel, blade
Artisan View
👀 Manage your views in Laravel projects through artisan
Stars: ✭ 708 (+972.73%)
Mutual labels:  laravel, blade
Fortify Ui
Laravel Fortify driven replacement to the Laravel UI package
Stars: ✭ 192 (+190.91%)
Mutual labels:  laravel, blade
Beautymail
Send beautiful HTML emails with Laravel
Stars: ✭ 923 (+1298.48%)
Mutual labels:  laravel, blade
Laravel Blade Directives
A collection of nice Laravel Blade directives
Stars: ✭ 813 (+1131.82%)
Mutual labels:  laravel, blade
Themevel
Theme and asset management for laravel
Stars: ✭ 278 (+321.21%)
Mutual labels:  laravel, blade
Larawind
Larawind - Laravel 8.0+ Jetstream and Tailwind CSS Admin Theme
Stars: ✭ 55 (-16.67%)
Mutual labels:  laravel, blade
Shopper
An eCommerce administration built with Laravel 5 for create online shop.
Stars: ✭ 205 (+210.61%)
Mutual labels:  laravel, blade
Laravel Blade Javascript
A Blade directive to export variables to JavaScript
Stars: ✭ 485 (+634.85%)
Mutual labels:  laravel, blade
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (+200%)
Mutual labels:  laravel, blade
Blade
🔪 A standalone version of Laravel's Blade templating engine for use outside of Laravel.
Stars: ✭ 542 (+721.21%)
Mutual labels:  laravel, blade
Laravel Markdown
A small, lightweight and easy-to-use Laravel package for handling markdown.
Stars: ✭ 185 (+180.3%)
Mutual labels:  laravel, blade
Laravel Bootstrap Components
Bootstrap components as Laravel components
Stars: ✭ 190 (+187.88%)
Mutual labels:  laravel, blade
Laravel Notify
Flexible Flash notifications for Laravel
Stars: ✭ 787 (+1092.42%)
Mutual labels:  laravel, blade
Tailwindcss
A Tailwind CSS frontend preset for the Laravel Framework
Stars: ✭ 1,056 (+1500%)
Mutual labels:  laravel, blade

laravel-tinymce-simple-imageupload

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].