Hi Lewis,
On Feb 28, 2009, at 7:14 PM, Lewis Denizen wrote:
Hi xwiki-users,
In XWiki Syntax 1.0, I was able to do something like this:
<a href="${documentURLRoot}"><img
src="$xwiki.getSkinFile('icons/black-file.png')" alt="Root
URL"
title="Root
URL" /></a>
This would render an icon from the current skin as a link. I
understand
that in XWiki Syntax 2.0, there's a new form of this available:
[[image:Space.Wiki@picture.png>>${documentURLRoot}]]
Since $documentURLRoot is velocity syntax you'd need to wrap it in
{{velocity}} macro but indeed it'll still not work for the moment
since the link syntax supports either absolute URL or document
references but not relative paths.
So right now you'd need to make documentURLRoot absolute. There are
some xwiki api to do so.
This works if the image exists in your document as an
attachment, but
doesn't work when the image link is relative to your web context:
[[image:$xwiki.getSkinFile('icons/black-file.png')>>$
{documentURLRoot}]]
Same here, the image syntax doesn't support relative paths.
I guess we could improve the link and image syntax to support paths
starting with "/" and then consider them as paths relative to the
context root. However it wouldn't work for relative paths such as
"../../some/path".
Right now we could easily add a XWiki API to get an absolute URL from
a relative one.
Note that you can still use the old syntax using the {{velocity}}
{{html}}<a href="..."...{{/html}}{{/velocity}} but that's not very
nice and it would be nice if it could be written using the new syntax
but was made to avoid using HTML... :)
Would recognizing references starting with "/" a good solution for
you? What do others think?
This renders as the following:
<a
href="http://www.google.com/">
<img alt="/xwiki/skins/albatross/icons/black%2Dfile.png"
class="wikimodel-freestanding"
src="/xwiki/bin/download/XWiki/WebHome/%2Fxwiki%2Fskins%2Falbatross
%2Ficons%2Fblack%252Dfile.png"/>
</a>
which is not what I expected... One workaround is to put an explicit
"http://server-name:port/" before the $xwiki.getSkin() call, but
that ties
the wiki to the server's address/port.
One other interesting thing I found out was that:
{{velocity}}
{{html wiki=true}}
BTW this is the default I think so no need to specify wiki=true AFAIR.
* this works - [[image:
http://localhost:8080/$xwiki.getSkinFile('icons/black-file.png')]]
* this doesn't work - <img
src=$xwiki.getSkinFile('icons/black-file.png')>
{{/html}}
{{/velocity}}
This is not correct. The html macro must contain HTML. This is not the
case in your example. You need this:
{{velocity}}
* this works -
[[image:http://localhost:8080/$xwiki.getSkinFile('icons/black-file.png')
]]
* this doesn't work - {{html}}<img src="$xwiki.getSkinFile('icons/
black-file.png')"/>{{/html}}
{{/velocity}}
It seems that the HTML Macro's final filter parses
this last test
case as 1
BulletedListBlock and 1 XMLBlock, but I'm not sure if this the
expected
behavior. If this is the expected behavior, the more need to get the
[[image:]] tag working...
Thanks again for the great job!
Thanks
-Vincent
http://xwiki.com
http://xwiki.org
http://massol.net