Fórum

CK Editor- Image Browser

thumbnail
Sreeraj AV, modificado 11 Anos atrás.

CK Editor- Image Browser

Regular Member Postagens: 239 Data de Entrada: 27/04/10 Postagens Recentes
Hi,

I'm trying to Integrate Liferay with Wordpress. I have created a custom portlet which can post blog to wordpress. In my Blog form, i have few fields like Blog Title, content, tags and categories. For content field i'm using CK editor. The problem is, i want to load images from Wordpress and put it in CK editir. For this i have added a button called "Wodpress Media Library" in my from. once i click on this button, it will open a popup window which will display images from wordpress. so i want to know how we can call CK image Properties window to load the selected images from wordpress popup window . Currently I'm using the given javascript code to load the image properties window of CK editor. the problem is when i'm clicking first time its not passing the image url to Image properties window..

attachimage function will be called when i click on a particular image from the popup window..

function attachImage(link){
CKEDITOR.tools.callFunction(43, this);
document.getElementById('cke_80_textInput').value=link;
}
when i'm trying with CKEDITOR.tools.callFunction(43, link) method, link is not loading in image properties ..



any help???
thumbnail
Sreeraj AV, modificado 11 Anos atrás.

RE: CK Editor- Image Browser (Resposta)

Regular Member Postagens: 239 Data de Entrada: 27/04/10 Postagens Recentes
Found the answer..


We can directly insert any html tag (eg: img tag in my case) to CKEditor using javascript.. see thisforum post

Previously i was trying to load image to image properties window, from there adding image to editor.. now i can directly insert image to editor using the given script..


this is my code..


<liferay-ui:input-editor width="100%" name="content" initMethod="initEditor" />

<script type="text/javascript">
		function <portlet:namespace />initEditor() {
				 return "<%= UnicodeFormatter.toString(post.getDescription()) %>"; 
		}
</script>
<script type="text/javascript">
function attachImage(link){
		var oEditor = CKEDITOR.instances.<portlet:namespace/>content;
		var html = '<img src="'+link+'"/>';
		var newElement = CKEDITOR.dom.element.createFromHtml( html, oEditor.document );
		oEditor.insertElement( newElement );
		}
</script>