Question

I want to upload image form local and to show it in textarea... Is there some free plugin, or could you explain me how to write one?

I have this code in :

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
tinymce.init({
    selector: "textarea#elm1",
    theme: "modern",
    //width: 600,
    height: 300,
    file_browser_callback: function(field_name, url, type, win) {
        if(type=='image') $('.slike').click();
    },
    plugins: [
         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor ",
   ],
   content_css: "css/content.css",
   toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons", 
   style_formats: [
        {title: 'Bold text', inline: 'b'},
        {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
        {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
        {title: 'Example 1', inline: 'span', classes: 'example1'},
        {title: 'Example 2', inline: 'span', classes: 'example2'},
        {title: 'Table styles'},
        {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ],
 }); 
</script>

And this code in body:

<form id='my_form' action='' method='POST' enctype="multipart/form-data">
        Title:<br/>
        <input type='text' name='title'/><br/><br/>
        Content:<br/>
         <textarea id="elm1" name="area"></textarea>        
        <br/>
        <input class='slike' name="image[]" multiple="multiple" type="file">
        <input type='submit' name='submit' value='Ok!'/>
    </form>
Was it helpful?

Solution

I had the same issue a couple of weeks ago.

First of all is important to be concern about the tinymce textarea will shows images and elements like a web browser will do, so you must to enter a right path for the href atribute image label (external published url o local url).

Once you ensure the url, you will change your configuration in order to avoid the tinyMce control will drop the image label from your code. I got this point with this configuration (using absolute paths):

tinyMCE.init({
    ...
    //your initialization rules
    ...
    // Drop lists for link/image/media/template dialogs
    template_external_list_url : 'lists/template_list.js',
    external_link_list_url     : 'lists/link_list.js',
    external_image_list_url    : 'lists/image_list.js',
    media_external_list_url    : 'lists/media_list.js',
    relative_urls              : false,
    remove_script_host         : false,
    convert_urls               : true,
    extended_valid_elements    : 'iframe[src|frameborder|style|scrolling|class|width|height|name|align]'
    });

I hope this code will help you!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top