Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML : Is there any way to show images in a textarea?

So I want to show image thumbnails too in the <textarea> along with text. If you know a javascript solution that's perfect too(if possible in vanilla JS).

Like this:

__________________ |Hello World     | |  _______       | |  | Img |       | |  |     |       | |  |_____|       | |Hello again.    | |  _______       | |  | Img2|       | |  |     |       | |  |_____|       | |________________| 

As I know and seen in a div or anything what has contentEditable="true" allows image too but, allows many other HTML tags and a lots of things what I don't want :|

I want just text and images.

like image 568
Adam Halasz Avatar asked Sep 25 '10 08:09

Adam Halasz


1 Answers

Use a div with contentEditable attribute which acts like a textarea. That's how wysiwyg editors are created.

div {    width: 300px;    height: 200px;    border: 1px solid #ccc;  }
<div contentEditable="true">Type here. You can insert images too    <img src="http://t2.gstatic.com/images?q=tbn:ANd9GcQCze-mfukcuvzKk7Ilj2zQ0CS6PbOkq7ZhRInnNd1Yz3TQzU4e&t=1" />  </div>
like image 115
Hussein Avatar answered Oct 08 '22 09:10

Hussein