Reputation: 51
Does anyone know how to insert images into qute template? I tried to write something in my HTML like:
<img src="../../../resources/templates/imgs/test.jpg" alt=""/>
but always got exception:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
and a lot of symbols of image code.
And the same question if image is SVG format.
Upvotes: 5
Views: 1418
Reputation: 10539
You shouldn't include images into the templates
directory as otherwise they will get parsed by Qute as templates.
Just store the images in a directory outside of the templates
directory. If you want them to be accessible as static resources, they should be in src/main/resources/META-INF/resources
.
Note that you can also prevent Qute from parsing some files with quarkus.qute.template-path-exclude
- https://quarkus.io/guides/qute-reference#quarkus-qute_quarkus.qute.template-path-exclude .
Note:
If your are creating web application your relative path of the static assets should be same.
For example you are rendering an html file. You have some static assets in that html. Your html path is http://localhost:8080/your-app/v1/product/1. In this example the resource path is your-app/v1/product
. So you should place static assets in src/main/resources/META-INF/resources/v1/product
But I don't think that's what you want as in any case, your images need to be accessible as static content.
Upvotes: 3
Reputation: 51
Works only variant with base64 : <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ........" alt=""/>
Upvotes: 0