hi all,
i'm writing a confluence plugin with a simple macro that shows some images, but i can't find a way to display them.
under the atlassian-plugin.xml the declaration for images folder is
<resource type="download" name="images/" location="images/" />
in my macro i use three different urls
<img src="$req.contextPath/download/resource/my.plugin.key/images/image.png" /><br /> <img src="$baseUrl/download/resource/my.plugin.key/image.png" /><br />
<img src="/download/resource/my.plugin.key/image.png" /><br />
but none of them will show me my image... i tried to put it in a <web-resource> tag too (and then, adding ":resources" after the plugin key), but i didn't get anything from that.. .this is driving me crazy!
one friend of mine said that on his app he has an url like this one
href="/confluence/s/it_IT/3278/363/1.0.0-SNAPSHOT/_/download/resources/another.plugin.key:my.resource.key/my-css.css"
so he told that my urls will never work... but how is that even possibile? and if it's true, how i can build that kind of url?
believe me, i read every single thread and i tried (almost, i guess!) everything, but i'm not being able to show an image on my macro: do you have some kind of suggestions?
thanks in advance,
marco
Community moderators have prevented the ability to post new answers.
Hi Marco,
Try this :
1) Create a folder called images under src/main/resources and put all your images there. Make sure your plugin knows where to find these images by creating a proper web resource for it in the atlassian-plugin.xml
2) Put all your html in a velocity file with extension .vm , under a directory /src/main/resources/vm
3) Try making your macro render the content from a vm :
public String execute(Map<String, String> parameters, String body, ConversionContext context) throws MacroExecutionException { Map<String, Object> contextMap = MacroUtils.defaultVelocityContext(); ... ... return VelocityUtils.getRenderedTemplate("vm/urvmfilename.vm", contextMap); }
it worked! i also changed my plugin key, which was a variable from maven pom.xml and i made it a plain string...
thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have added a image in my macro. This image is not showing in user mode after admin login its showing. when I'm coping the image resource and past in direct url then its asking for admin login. Please help.
/dowlaod/thumbnails/3344443/image-name.png
this is my root
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello yagnesh, thanks for your reply.
the macro works just fine, my problem is only with the resources. the only difference in my code was that i had this
VelocityContext contextMap = new VelocityContext(MacroUtils.defaultVelocityContext());
i changed it with your code but it didn't work. at the same time, i also put my <resource> tag under <web-resource>
<!-- add our web resources --> <web-resource key="resources" name="Analytics Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <context>atl.general</context> <!-- whole folder --> <resource type="download" name="images/" location="images/"> <property key="content-type" value="image/png"/> </resource> </web-resource>
then i added ":resources" next to my plugin key in the url, but nothing...
what's the difference between using <resource> under <web-resource> or under the <atlassian-plugin> tag?
and then, is there a way to "explore" all deployed resources under confluence or, at least, do some kind of debug during the plugin installation? just to check if my images are deployed: i'm starting to think that there is a problem in that phase because my code seems to be ok!
p.s.: i just checked and the plugin-logo image (declared under <plugin-info>) is shown correctly, so i guess it's not a deploying problem...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do the following changes to your code :
1) Make location="/images" (You have made it as "images/") . Try this first.
2) I am not sure if you need the <property> element - I have not used it in my projects so far.
These are some concerns I see in your code rightaway, so lets try changing these first.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.