Vlad Kurkin (b_vladi) wrote in changelog,
Vlad Kurkin
b_vladi
changelog

[livejournal] r19770: LJSUP-9255: Cannot upload image from com...

Committer: vkurkin
LJSUP-9255: Cannot upload image from computer
U   trunk/htdocs/js/entry.js
Modified: trunk/htdocs/js/entry.js
===================================================================
--- trunk/htdocs/js/entry.js	2011-08-18 07:38:06 UTC (rev 19769)
+++ trunk/htdocs/js/entry.js	2011-08-18 08:22:52 UTC (rev 19770)
@@ -860,13 +860,24 @@
 
 // image upload stuff
 InOb.onUpload = function (surl, furl, swidth, sheight){
-	var ta = $("updateForm");
-	if(! ta){
-		return InOb.fail("no updateform");
+
+	var html = "\n<a href=\"" + furl + "\"><img src=\"" + surl + "\" width=\"" + swidth + "\" height=\"" + sheight + "\" border='0'/></a>";
+
+	if (window.switchedRteOn) {
+		CKEDITOR.instances.draft.insertHtml(html);
+	} else {
+		var ta = $("updateForm");
+		if (!ta) {
+			return InOb.fail("no updateform");
+		}
+		ta = ta.event;
+
+		var selection = DOM.getSelectedRange($('draft'));
+		var value = ta.value;
+		var start = value.substring(0, selection.start);
+		var end = value.substring(selection.end);
+		ta.value = start + "\n" + html + end;
 	}
-	ta = ta.event;
-	ta.value = ta
-		.value + "\n<a href=\"" + furl + "\"><img src=\"" + surl + "\" width=\"" + swidth + "\" height=\"" + sheight + "\" border='0'/></a>";
 };
 
 InOb.onInsURL = function (url, width, height){

Tags: b_vladi, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments