Try the fastest and simplest way to install ONLYOFFICE

Insert images won't show at the first time, need refresh

Integration questions/issues

Insert images won't show at the first time, need refresh

Postby poplee » Fri Mar 23, 2018 5:46 am

Hi Maxim,

I use the plugin function to insert images into words in a field like this:
{
"Props" :
{
"Id" : 2,
"Tag" : "InsertImg",
"Lock" : 3
},

"Script" : "var oDocument = Api.GetDocument();var oParagraph = Api.CreateParagraph(); oDrawing = Api.CreateImage('http://xxxx/image001.png', 60 * 36000, 35 * 36000); oParagraph.AddDrawing(oDrawing);oDocument.InsertContent([oParagraph]);"
}

The problem is, every time after insertion, the images won't show directly, only a red cross there, I need to refresh the url to load the images. Any idea why this happened? and how can I fix it. Thanks.

Best,
poplee
 
Posts: 11
Joined: Wed Mar 14, 2018 3:44 am

Re: Insert images won't show at the first time, need refresh

Postby poplee » Thu May 10, 2018 7:22 am

Hi guys, any idea why I got this problem?
Any idea or comment is welcome. Thanks a lot.
poplee
 
Posts: 11
Joined: Wed Mar 14, 2018 3:44 am

Re: Insert images won't show at the first time, need refresh

Postby martiniano » Thu May 10, 2018 7:32 pm

Hello popiee
I've been going through the same problem.
And I have no idea how to solve it.
martiniano
 
Posts: 1
Joined: Thu May 10, 2018 7:26 pm

Re: Insert images won't show at the first time, need refresh

Postby Maxim » Fri May 11, 2018 2:18 pm

Hello!
It supports an image in base64 format only for now. But later we plan to support other formats.
Maxim
 
Posts: 1649
Joined: Tue Oct 11, 2016 2:34 pm

Re: Insert images won't show at the first time, need refresh

Postby poplee » Fri May 11, 2018 4:53 pm

martiniano wrote:Hello popiee
I've been going through the same problem.
And I have no idea how to solve it.


Hi martiniano, thanks.
I figured out a stupid way to refresh the images, I will share it here.

After inserted the target image, it won't show and need to refresh the whole web page, so I just run the following code, insert a very small image, you know what, the target image will display then. I don't know why but it works, hope it is useful to you .

var _val2 = "var oDocument = Api.GetDocument();var oParagraph, arrInsertResult = [], oImage;oParagraph = Api.CreateParagraph();arrInsertResult.push(oParagraph);oImage = Api.CreateImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAGUExURf///wAAAFXC034AAAABdFJOUwBA5thmAAAADElEQVR42mJgAAgwAAACAAFPbVnhAAAAAElFTkSuQmCC', 1 * 36000, 1 * 36000);oParagraph.AddDrawing(oImage);oDocument.InsertContent(arrInsertResult);";
oo_plugin_init.info.recalculate = true;
oo_plugin_init.executeCommand("close", _val2);
Last edited by poplee on Sat May 12, 2018 1:48 am, edited 1 time in total.
poplee
 
Posts: 11
Joined: Wed Mar 14, 2018 3:44 am

Re: Insert images won't show at the first time, need refresh

Postby poplee » Fri May 11, 2018 4:54 pm

Maxim wrote:Hello!
It supports an image in base64 format only for now. But later we plan to support other formats.

Thanks Maxim anyway, it's not a format problem I think. Actually, it won't show in any format.
poplee
 
Posts: 11
Joined: Wed Mar 14, 2018 3:44 am

Re: Insert images won't show at the first time, need refresh

Postby Maxim » Wed May 16, 2018 7:55 am

Hello poplee!
Thank you for your info and feedback!
Maxim
 
Posts: 1649
Joined: Tue Oct 11, 2016 2:34 pm


Return to Plugins

Who is online

Users browsing this forum: No registered users and 1 guest

cron