Images into Qute Template

Viewed 377

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.

2 Answers

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 .

But I don't think that's what you want as in any case, your images need to be accessible as static content.

Works only variant with base64 : <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ........" alt=""/>

Related