Image URL when previewed in Notes and in Web Browser

主宰稳场 提交于 2019-12-11 04:07:25

问题


Lets say we have a XPage with following code snippet which displays an image using javascript formula:

<xp:image id="image1"><xp:this.url><![CDATA[#{javascript:"actn005.gif"}]]></xp:this.url></xp:image> 

actn005.gif is present in the current database as image resource. When I click on the "Preview in Notes" and get the source it displays something like this for Image:

<img id="view:_id1:image1" src="/xsp/Naveen/Experiments.nsf/xsp/actn005.gif" alt="" class="xspImage">

When I click on the "Preview in Web Browser" and get the source it displays something like this for Image:

<img id="view:_id1:image1" src="/Naveen/Experiments.nsf/actn005.gif" alt="" class="xspImage"> 

You can see that in case of "Preview in Notes" it adds xsp before and after the path of the database. My question is WHY? The image displays in both cases with no issues. But if I have XPage which renders image lets call it - XPage_Rendering_Image.xsp. Because of which the XPage code

<xp:image id="image1"><xp:this.url><![CDATA[#{javascript:"XPage_Rendering_Image.xsp"}]]></xp:this.url></xp:image> 

renders as:

<img id="view:_id1:image1" src="/xsp/Naveen/Experiments.nsf/xsp/XPage_Rendering_Image.xsp" alt="" class="xspImage"> 

and then it FAILS! I posted this question earlier on XPages forum and was suggested using a normal image tag like

<img src="#{javascript:'XPage_Rendering_Image.xsp'}" alt="" class="xspImage" />.

But is there a way to make this work using <xp:image> tag? Is this a bug?


回答1:


It might not work as you would like it (and many others), but it works as designed. If you want to provide your own image source (I presume the XPage_Rendering_Image.xsp is an XAgent) you have to use the Extension API and provide a resource renderer. Or you stick with the standard html img tag as suggested in the forum. The XSP path part in the Notes client is needed so the local web server can recognize that it is to be rendered by the XSP engine and not a classic client part.

Update: the /xsp/.... URL works on the web too. So that's what you need.




回答2:


I would like this to be considered as bug and fixed by IBM. I have also encountered this discrepancy and found no solution (conditional rendering based on client/browser is not an option).

For example, native link to "$Icon" image resource does not work either.



来源:https://stackoverflow.com/questions/9363885/image-url-when-previewed-in-notes-and-in-web-browser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!