How to display image from Media in a Velocity template?

I’m unable to figure out how to display an image stored in the Servoy Media of a solution within a report generated by Velocity; what actually goes into the HTML template? There is reference to using plugins.getMedia() (which doesn’t seem to exist, although solutionMode.getMedia() does) but not what the syntax is within the template itself to display the image.

The FAQ references getImageTag() but I also cannot figure out what the ```
<img src=“theinternalURLOfYourBlobObject”


Anything would be much appreciated as I'm sure it must be quite simple.

Thanks in advance.

For anyone else that has come across this; the variable is passed directly into the context object. As an example:

{ foundset: myFoundSet, Logo: myLogo, currency: "$#,##0.00" }

This can then be referenced in the HTML as:
$myLogo

The tag syntax I found confusing is that the theinternalURLOfYourBlobObject is what the variable is translated into, not what you should be using.

Hope this helps.

Hi Roddy,

You can embed the whole image in the template like so:

var template = '<html><head></head><body><p>$myLogo</p></body></html>'; 
// no img tag needed, it will be generated for you

var context = {myLogo: plugins.VelocityReport.getByteMedia(foundset.logo)};
// parameter options are getByteMedia(bytes, [id], [width], [height], [cssClass]): 

application.output(plugins.VelocityReport.evaluateWithContext(template, context));

Hope this helps.

Reading your post again I see you actually wanted to use an image that is part of the solution. You can use the same code with a slight change:
Use solutionModel.getMedia(‘myLogo.png’).bytes instead of foundset.logo.

So the code would look like this:

var template = '<html><head></head><body><p>$myLogo</p></body></html>'; 
// no img tag needed, it will be generated for you

var context = {myLogo: plugins.VelocityReport.getByteMedia(solutionModel.getMedia('myLogo.png').bytes)};
// parameter options are getByteMedia(bytes, [id], [width], [height], [cssClass]): 

application.output(plugins.VelocityReport.evaluateWithContext(template, context));

Hope this helps.

Thanks for that, much appreciated :-)