# How to display image from Media in a Velocity template?

**URL:** <https://forum.servoy.com/t/how-to-display-image-from-media-in-a-velocity-template/20552>\
**Category:** Questions\
**Created:** [August 2, 2021, 4:32am UTC](https://forum.servoy.com/t/how-to-display-image-from-media-in-a-velocity-template/20552 "2021-08-02T04:32:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![roddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@roddy](https://forum.servoy.com/u/roddy)\
**Post date:** [August 2, 2021, 4:32am UTC](https://forum.servoy.com/t/how-to-display-image-from-media-in-a-velocity-template/20552/1 "2021-08-02T04:32:02Z")

</div>

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”

```auto

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

Thanks in advance.
```

---

<div class="post-metadata">

**Author:** ![roddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@roddy](https://forum.servoy.com/u/roddy)\
**Post date:** [August 2, 2021, 5:25am UTC](https://forum.servoy.com/t/how-to-display-image-from-media-in-a-velocity-template/20552/2 "2021-08-02T05:25:07Z")

</div>

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

```auto
{ 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.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [August 2, 2021, 7:53am UTC](https://forum.servoy.com/t/how-to-display-image-from-media-in-a-velocity-template/20552/3 "2021-08-02T07:53:10Z")

</div>

Hi Roddy,

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [August 2, 2021, 9:24am UTC](https://forum.servoy.com/t/how-to-display-image-from-media-in-a-velocity-template/20552/4 "2021-08-02T09:24:33Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![roddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@roddy](https://forum.servoy.com/u/roddy)\
**Post date:** [August 3, 2021, 12:46am UTC](https://forum.servoy.com/t/how-to-display-image-from-media-in-a-velocity-template/20552/5 "2021-08-03T00:46:22Z")

</div>

Thanks for that, much appreciated ![:-)]( "Smile")
