CodeIn House

  • Laravel
  • WordPress
  • jQuery
  • Javascript
  • Contact
Home   Laravel   How to Install TinyMCE in Laravel Along with Image Upload Wi ...

How to Install TinyMCE in Laravel Along with Image Upload With Responsive File Manager ?

April 2, 2017 by SNK

install tinymce laravel

Today in this tutorial we are going to see how we are going to install tinymce in laravel. One good thing about tinymce is that it is very light weight and can be easily used across any website.

Most popular CMS like WordPress also use it as their editor to add content in the website. If it is integrated with responsive file manager plugin it would be even better to upload images via file manager.

Lets get started :-

What we are going to do ?

  1. Download Lightweight version of tinymce from here.
  2. Download Responsive File manager plugin from here. here

It is very easy to integrate tinymce in laravel. I had even break down them in small steps so that you could easy understand it.

Get your things ready and head over to first step.

Step 1:-

Extract the zip package inside the public folder of laravel project directory. Your laravel public directory and tinymce directory would look like the image below :-

tinymce and laravel public folder structure

Step 2 :-

Once you have extracted the package exactly like the image above, now its time to call the plugins in your header area. Initiate the js call using the codes below.

index.blade.php
JavaScript
1
2
3
<script src="{{url('tinymce/jquery.tinymce.min.js')}}"></script>
<script src="{{url('tinymce/tinymce.min.js')}}"></script>
<script>tinymce.init({ selector:'#ckview' });</script>

Now use the selector as and id in your textarea like below :-

index.blade.php
PHP
1
<textarea name="editor" id="ckview" cols="30" rows="10">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis hic doloremque ex corporis provident recusandae. Molestias alias dignissimos molestiae minus quia consectetur sint, maxime quidem. Repellat temporibus similique iusto eaque.</textarea>

This is pretty much to add the tinymce editor in your textarea. You can do almost all the things except uploading files and images with the editor.

How to Integrate Responsive File manager with TinyMCE ?

Since,we have integrated tinymce with textarea as our editor, we still cant upload any files and images with the editor.

To enable file-manager in tinymce we are going to use third party plugin called responsive file-manager inside tinymce to let us to uploads directly through the editor.

Step 1 :-

Take this step very carefully !! There are two things that needs to be done in this step.

First, extract responsive file manager zip package. There are minimum 4 folders two of them are named file manager and tinymce.

Go inside tinymce and inside plugins folder and copy that responsivefilemanager folder inside laravel public/tinymce/plugins folder and paste it.

Next, step is to copy the file manager folder into the public folder inside tinymce.

After you place the plugins files and folders correctly like above its time to initialize the plugin and set the base path.

Lets add the codes provided by responsive file manager to enable file manager inside the editor and initiate the call.

index.blade.php
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
tinymce.init({
selector: "#ckview",theme: "modern",width: 680,height: 300,
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor responsivefilemanager code"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor  | print preview code ",
image_advtab: true ,
external_filemanager_path:"{{url('tinymce/filemanager')}}/",
filemanager_title:"Responsive Filemanager" ,
external_plugins: { "filemanager" : "{{url('tinymce')}}/filemanager/plugin.min.js"}
});

Once you have integrated the file manager code and initiated the call, its time to fix the base path for image. Go to public\tinymce\filemanager\config\config.php

Find this piece of code in config.php

config.php
PHP
1
'upload_dir' => '/source/',

And replace with this

config.php
PHP
1
'upload_dir' => getenv('APP_ROOT_PATH').'/public/tinymce/source/',

Thats it, Save up everything and try reloading the browser to check the textarea to see if the editor and file manager have been enabled or not.

Take a look at full code below :-

index.blade.php
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Simple Tiny MCE With Resonsive FileManager Implementation</title>
<link rel="stylesheet" href="">
<script src="{{url('tinymce/jquery.tinymce.min.js')}}"></script>
<script src="{{url('tinymce/tinymce.min.js')}}"></script>
</head>
<body>
<style>
* {
margin:10px auto;
text-align: center;
}
</style>
<div style="width: 800px;" class="center">
<form action="">
<textarea name="editor" id="ckview" cols="30" rows="10">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis hic doloremque ex corporis provident recusandae. Molestias alias dignissimos molestiae minus quia consectetur sint, maxime quidem. Repellat temporibus similique iusto eaque.</textarea>
</form>
</div>
 
<script>
tinymce.init({
selector: "#ckview",theme: "modern",width: 680,height: 300,
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor responsivefilemanager code"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor  | print preview code ",
image_advtab: true ,
external_filemanager_path:"{{url('tinymce/filemanager')}}/",
filemanager_title:"Responsive Filemanager" ,
external_plugins: { "filemanager" : "{{url('tinymce')}}/filemanager/plugin.min.js"}
});
</script>
</body>
</html>

If you have any problem you can mention it via comments.

SHARE ON
Buffer

Enjoyed this article?

Like us on

Laravel install tinymce laravel laravel tinymce image upload

Avatar for SNK

About SNK

Hello Welcome to my Blog. I develop Websites Using Laravel Framwork & WordPress. Get Latest updates on Facebook | Twitter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get Connected !! With Us

TOP POSTS

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

TUTORIALS TILL DATE

  • September 2022 (6)
  • June 2021 (7)
  • October 2020 (5)
  • September 2020 (6)
  • September 2018 (14)
  • August 2018 (3)
  • July 2018 (4)
  • March 2018 (8)
  • February 2018 (5)
  • January 2018 (1)
  • December 2017 (2)
  • August 2017 (8)
  • May 2017 (1)
  • April 2017 (1)
  • March 2017 (4)
  • February 2017 (3)
  • January 2017 (4)

CATEGORIES

  • Angular (2)
  • CSS3 (3)
  • D3 (3)
  • HTML5 (7)
  • JAVA (11)
  • Javascript (20)
  • jQuery (8)
  • Laravel (35)
  • Others (3)
  • PHP (11)
  • Spring (2)
  • WordPress (10)

Top Categories

  • Angular
  • CSS3
  • D3
  • HTML5
  • JAVA
  • Javascript
  • jQuery
  • Laravel
  • Others
  • PHP
  • Spring
  • WordPress

Get in Touch

DMCA.com Protection Status

Recent Articles

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

© 2012-22 CodeIn House.  •  All Rights Reserved.