CKEditor Images Upload using Yii2 – TinyMCE
In this Post We Will Explain About is CKEditor Images Upload using Yii2 – TinyMCE With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to CKEditor file upload in Yii2 Example
In this post we will show you Best way to implement Yii2, CKEditor and Images Upload, hear for Image Uploader and Browser for CKEditor in Yii2 with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
CKEditor structure
The structure will be
Tinymce –js –tinymce — external libs — tinymce.min.js
Include External Libs
Call simple external libs CKEditor tinymce.min.js file to your yii project file.
<script src="tinymce/js/tinymce/tinymce.min.js"> </script>
index.html
<html> <head> <title>YII2 Tinymce with ImageUpload External Example</title> <style> .hidden{display:none;} .container { width: 1100px; margin: 0 auto; } .header, .body { width: 100%; float: left; margin-bottom: 32px; } .header img { width: 45%; float: left; } .header h2 { width: 50%; float: left; margin-left: 32px; font-size: 28px; line-height: 2 } .space { margin-bottom: 32px; margin-top: 32px; } </style> </head> <body> <div class="live container"> <div class="header"> <img src="http://www.Pakainfo.com/wp-content/uploads/2016/08/17logo-300x86.png"> <h2> Pakainfo.com - YII2 Tinymce with ImageUpload </h2> </div> <textarea name="live" id="live" cols="30" rows="10"></textarea> <input name="image" type="file" id="liveFileupload" class="hidden" onchange=""> </div> <script src="tinymce/js/tinymce/tinymce.min.js"> </script> <script type="text/javascript"> tinymce.init({ selector: "textarea", theme: "modern", paste_data_images: true, plugins: [ "pagebreak autolink image charmap lists link print preview hr anchor advlist", "searchreplace visualblocks wordcount visualchars code fullscreen", "table insertdatetime media directionality nonbreaking save contextmenu", "textcolor colorpicker emoticons template textpattern paste" ], toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image", toolbar2: "print preview media | forecolor backcolor emoticons", image_advtab: true, file_picker_callback: function(callback, value, datameta) { if (datameta.filetype == 'image') { $('#liveFileupload').trigger('click'); $('#liveFileupload').on('change', function() { var file = this.files[0]; var dataread = new FileReader(); dataread.onload = function(e) { callback(e.target.result, { alt: '' }); }; dataread.readAsDataURL(file); }); } }, templates: [{ title: 'Pakainfo.com Website 1', content: 'Live24u 1' }, { title: 'Pakainfo.com Website 2', content: 'Live24u 2' }] }); </script> </html>
index.js
Init simple tinymce yii to textarea
tinymce.init({ selector: "textarea", theme: "modern", paste_data_images: true, plugins: [ "pagebreak autolink image charmap lists link print preview hr anchor advlist", "searchreplace visualblocks wordcount visualchars code fullscreen", "table insertdatetime media directionality nonbreaking save contextmenu", "textcolor colorpicker emoticons template textpattern paste" ], toolbar1: "bold italic | styleselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | insertfile undo redo ", toolbar2: "print preview media | forecolor backcolor emoticons", image_advtab: true, file_picker_callback: function(callback, value, datameta) { if (datameta.filetype == 'image') { $('#liveFileupload').trigger('click'); $('#liveFileupload').on('change', function() { var file = this.files[0]; var dataread = new FileReader(); dataread.onload = function(e) { callback(e.target.result, { alt: '' }); }; dataread.readAsDataURL(file); }); } }, templates: [{ title: 'Pakainfo.com Website 1', content: 'Live24u 1' }, { title: 'Pakainfo.com Website 2', content: 'Live24u 2' }] });
For yii 2 :
Place this Free file browser for CKEditor and TinyMCE folder in vendor folder and render js from vendor folder Like below script
<script src="../../vendor/tinymce/js/tinymce/tinymce.min.js"> </script>
Thats it Last We can access this source code for YII2 also.
You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example
I hope you have Got What is Image Uploader and Browser for CKEditor in Yii2 And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.