Skyr answer does not work for my version of Play (2.4.2). Using this method results in the following compilation error:
Value in is not a member of the controllers. Reverseversessets
After consulting the documentation, this works for me:
<img src="@routes.Assets.versioned("images/yourImage.png")">
where yourImage.png is in public/images .
If you want to speed up page loading by caching and compressing your images (and all other assets of your web application), try the following:
Make sure your plugins.sbt contains the following entries:
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7") addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0") addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
Then in build.sbt add the following:
// Apply RequireJS optimizations, create a checksum, and zip each asset pipelineStages := Seq(rjs, digest, gzip)
source share