TinyMCE WYSIWYG Editor - elFinder Image Upload with Character Counter.
Limit the number of characters.

    File Structure:
  • index.php
  • seteditor.php
  • media
  • -- .trash
  • js
  • -- eltheme-jquery-ui.min.css
  • -- jquery.min.js
  • -- jquery-ui.min.js
  • -- elfinder.min.js
  • -- tinymceElfinder.js
  • Download Scripts 269Kb
  • tinymce

I had a need to limit the number of characters that someone can enter into the editor while I was designing the Social Sharing module for HomePage CMS. I wanted to be able to set the limit so people wouldn't just put a lot of senseless text in their Bio and Interest fields. After a lot of searching and a lot of trial and error I finally came up with this solution.

In this tutorial we are going to add TinyMCE 7 and elFinder to the build and add the ability to upload images.
We are also going to change the word count to character count and limit the number of characters that can be entered.
I am assuming that you have already downloaded TinyMCE 7 and elFinder 2.1.65
If you download the Source .zip at the end of the tutorial they are included and that is the best way to get up and running.
Quick Start - Download the source.zip file and unpack it onto your server. Point your browser to the folder and it will run out of the box.
    Getting Started:
  • Create the media folder and open it.
  • Inside create the folder .trash (be sure to add the . )
  • Download the .js files.

Create a new file and name it seteditor.php
Copy/paste the following into it.

Copy/paste the following just below the last </script>.
We are naming the selector editor_one. This can be changed to anything else.
We also added plugins to the menubar and toolbars.

Now lets change word count to character count.
Copy/paste the following just below promotion: false,

The next step adds character handling, counting, and limiting features.
Copy/paste just below word count to character count.

index.php
The final step adds the editor to the build. Create a file and name it index.php.
Copy/paste the following.
In the <textarea set maxlength="" to the number of characters allowed in the editor.
Make sure that the selector, id, and the id in the <div are the same. In our case it is editor_one.
And in the <div that the id is followed with _countdown (editor_one_countdown).

 

Notice that the character count is 0,
place your cursor after the 35. in the editor and press the space bar to register the characters that are in the editor now.
Continue pressing the space bar to see the popup notice.

Download Source 2.42Mb

Download Tutorial 3.1Kb

Download Scripts 269Kb