简体   繁体   English

如何使用附加图像作为 src<img> XWiki 中的 {{html}} 内

[英]How to use attached image as src on <img> inside {{html}} in XWiki

I have an embedded html block in an XWiki page using {{html}}我在使用{{html}}的 XWiki 页面中有一个嵌入的 html 块

Inside this {{html}} , I have an <img> element.在这个{{html}} ,我有一个<img>元素。 I am able to get it working when the src attribute of this img is pointing to a public url like "http://example.com/image.png".当这个imgsrc属性指向一个像“http://example.com/image.png”这样的公共 url 时,我能够让它工作。

But, I couldn't figure out a way to use one of the images attached on this page as the src .但是,我想不出一种方法来使用此页面上附加的其中一个图像作为src

Any help is highly appreciated !任何帮助都非常感谢!

The best is not use HTML for that and instead use XWiki Syntax 2.0+ to create the attachment link.最好不要为此使用 HTML,而是使用 XWiki Syntax 2.0+ 来创建附件链接。 If, for some reason, you have to use the HTML macro, then pass wiki=true to it (and use the wiki markup for defining an attachment link).如果由于某种原因必须使用 HTML 宏,则将wiki=true传递给它(并使用 wiki 标记来定义附件链接)。 See the reference documentation at https://extensions.xwiki.org/xwiki/bin/view/Extension/HTML%20Macro .请参阅https://extensions.xwiki.org/xwiki/bin/view/Extension/HTML%20Macro 上的参考文档。

The last option is to use the Velocity macro ( https://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity%20Macro ) around the HTML macro, to compute the path to the attachment, using the $doc.getAttachmentURL() API.最后一个选项是在 HTML 宏周围使用 Velocity 宏 ( https://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity%20Macro ),使用$doc.getAttachmentURL()计算附件的路径$doc.getAttachmentURL() API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM