简体   繁体   中英

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}}

Inside this {{html}} , I have an <img> element. 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".

But, I couldn't figure out a way to use one of the images attached on this page as the 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. 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). See the reference documentation at 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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