Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6253559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:01:17+00:00 2026-05-24T14:01:17+00:00

I wonder if theres a way to add a html code to the tinymce

  • 0

I wonder if theres a way to add a html code to the tinymce textbox through a link outside the texbox. Say we have a link that looks like this:

<a href="#" onclick="addimage"><img src="img.jpg" width="30px" height="30px" /></a>

And when i click the link img.jpg I would like img.jpg added to the textbox appearing as an image.
So basicly adding an image to the textbox without having to drag it there.

Best regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:01:18+00:00Added an answer on May 24, 2026 at 2:01 pm

    You can embed a javascript function and a handler in the tinymce parent page (the page your image is located at). This function would call something like the following

    to_add = clicked_element.parentNode.innerHTML;
    tinymce.get(editor_id).execCommand('mceInsertContent', false, to_add);
    

    UPDATE: Here is an example. You might need to tweak this code a bit, casue it will only work if the image you clicked is the only child of its parent. I suggest du work with the image attributes here instead of element.parentNode.innerHTML

    // function to enter html element to caret position in editor
    function add_element_to_tinymce(elem, editor_id){
      var editor = editor_id ? tinymce.get(editor_id) : tinymce.editors[0];
      editor.execCommand('mceInsertContent', false, elem.parentNode.innerHTML);
    }
    
    // add jQuery handler to all images on the page
    jQuery('img').bind('click', function (evt){ add_element_to_tinymce(this);  });
    

    UPDATE2: This is the implementation of my own suggestion:

    // function to enter html element to caret position in editor
    function add_element_to_tinymce(element, editor_id){
      var editor = editor_id ? tinymce.get(editor_id) : tinymce.editors[0];
      var doc = editor.getDoc();
      var new_p = editor.getDoc().createElement('p');
      var new_img = $(element).clone().get(0);
      $(new_p).append(new_img);
      editor.execCommand('mceInsertContent', false, new_p.innerHTML);
    }
    
    // add jQuery handler to all images on the page
    jQuery('img').bind('click', function (evt){ add_element_to_tinymce(this);  });
    

    UPDATE3: inserts image element + src attribute only:

    // function to enter html element+src only to caret position in editor
    function add_element_to_tinymce(element, editor_id){
      var editor = editor_id ? tinymce.get(editor_id) : tinymce.editors[0];
      var doc = editor.getDoc();
      var new_p = editor.getDoc().createElement('p');
      var new_img = editor.getDoc().createElement('img');
      $(new_img).attr('src', $(element).attr('src'));
      $(new_p).append(new_img);
      editor.execCommand('mceInsertContent', false, new_p.innerHTML);
    }
    
    // add jQuery handler to all images on the page
    jQuery('img').bind('click', function (evt){ add_element_to_tinymce(this);  });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if there's a way to do the following: I have a structure
Let's say, for the sake of argument, that I have 30 asp.net web applications
I have to code a Java program that will receive messages from network and
I wonder what's the most effective way to render ANYTHING that might come from
I have a LinearLayout view that already contains several elements. I want to add
I wonder if there is a way or a workaround to have the config
I just wonder there a way to display the files in document directory with
I wonder if there's any way to do a while loop in django (I
I wonder if there exists way to work with large files in Mathematica ?
I wonder if there's some way of doing this, or even if it should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.