Scala – How to show images using Play framework and Scala in the view page


Using the Play framework, I'm trying to show the image friend_request.png in the view page.

This is my code but the image is not showing:

<img src=@("images/friend_request.png") width="28" height="22" />

Best Solution

I assume you want to include a static image, and since you're talking about Scala, I assume you're using Play Framework 2.

The appropriate place of the image in the standard project layout should be public/images/friend_request.png. You can then refer to the image:

<img src=""images/friend_request.png")" width="28" height="22" />

For more information on assets (caching time, etc.), please refer to the Play Framework documentation.

Related Question