I am migrating a set og wordpress blogs to clearspace community 2.4.0. While recreating those blogs in clearspace(Using webservice APIs) I want to add the images in the blogpost body also. After adding that image to the blogpost, I want to update the src attribute of the img html tag too.
But how will I get the link of an image after adding it to blogpost?
void addImageToBlogPost(long blogPostID, java.lang.String name, java.lang.String contentType, byte[] source)
This method returns void. Could you please also explain the APi usage for creating a blogpost with image inside?
Hi,
The addImageToBlogPost webservices call will take a image file stream that you give it and automatically upload it to your Clearspace instance and associate it with the specified blog post. When you are viewing this blog post you will be able to access this image by clicking on the Image button in the Rich Text Editor. Your new image will show up in the list of Uploaded images.
If you want to retrieve the name of this image via webservices you will want to use the getImagesByBlogPostID method:
This will an array of images associated with this blog post. Once you have the filename of the image that you want you can add it to your post by using this syntax:
!myFileName.jpg|alt=MyFileName.jpg!
Thanks.
-Todd
Hi,
My blog body is in html format and I adding {code:html} at the beginning of the data before passing to the API.
But how can I use wiki format !myFileName.jpg|alt=MyFileName.jpg! in html? In html we need to give the img tag with src attribute, right? Please correct me if I am wrong.
Thanks
Santhosh
Hi Santhosh,
Since you are using the {code:html} macro you will not be able to use the src attribute of the img tag. All "src" tags are stripped out of posts automatically to avoid any possible XSS (Cross Site Scripting) attacks. The only way for you to use images in your post via web services is to close your {code} macro when you are going to insert an image, use the !myFileName.jpg|alt=MyFileName.jpg! markup and then start a new {code:html} macro again.
Of course, this is all assuming that you are running Clearspace 2.0.x and not Clearspace 2.5. If you have any further questions please let me know. Thanks.
-Todd
I am using clearspace 2.0. What is the difference in this feature in 2.5 version?
I tried your solution in using web UI and it is working. But wont it fail when we close the html tag tree structure in betwee using {code} (ie. without closing all tags that were opened) ?
But when I tried the same using webservice APIs it is failing.
when I say the content of the blogpost as
{code:html}html content goes here{code} !image1.jpg|alt=image1.jpg!
But the when we see the result in webpage it is correct html and !image1.jpg|alt=image1.jpg! is coming as such in body of the blog
Hi Santhosh,
Unfortunately, after some extensive testing it appears that this kind of functionality is not possible. Even when done from the front-end it doesn't seem to be possible to have the HTML macro mixed with the wiki syntax at all. I believe that this is somewhat different in 2.5 because wiki markup has basically been eliminated and we've moved to an HTML only implementation. You might be able to achieve this functionality in 2.5 but I am not sure about 2.0.x.
If you have any further questions please let me know. Thanks.
-Todd
Is it possible to get the wiki formatted content of a blog published using webservice APIs? Or can we convert out HTML data to wiki format and then replace the image links using wiki syntax?
Hi,
I don't think that you can retrieve the wiki formatted content of a blog but you should be able to send in wiki text directly. If you can convert your HTML to wiki text automatically you should be able to embed images just fine using the wiki syntax. Thanks.
-Todd
Jive combines collaboration software, community software & social networking software into the leading SBS solution.
© Copyright 2000–2009 Jive Software. All rights reserved.
915 SW Stark St., Suite 400, Portland, OR 97205