Home > database >  Image not loading in Thymeleaf
Image not loading in Thymeleaf

Time:05-24

I'm trying to load an image from my project's local storage in email with thymeleaf but it won't !

<img src="../static/img/logo.png" alt="MyPicture" th:src="@{img/logo.png}">

although when i try with an absolute path it's perfectly loading

<img src="C:/Workspace/myProject/src/main/resources/static/img/logo.png" alt="MyPicture">

My images are stored in static/img

project tree here

CodePudding user response:

The image path shall start with a forward slash like

<img alt="MyPicture" th:src="@{/img/logo.png}">

CodePudding user response:

try changing your path to

<img src="img/logo.png" alt="MyPicture">

and you might also want to invalidate cache from your IDE settings for the image to be detected

  • Related