1

I have tried these solutions :

<img th:src="@{/resources/images/logo.png}"/>
<img th:src="@{../images/logo.png}"/>
<img th:src="@{classpath:images/logo.png}"/>

In all cases I am getting a

Link base "/resources/images/logo.png" cannot be context relative (/)

How can I fix this?

thomas
  • 1,201
  • 2
  • 15
  • 35
  • In general, for web pages: [Can I embed a .png image into an HTML page?](https://stackoverflow.com/q/2807251/12567365) but also, more specifically for your e-mail scenario: [How do i attach image in email...?](https://stackoverflow.com/q/63625403/12567365). If you can make it work with "hard-coded" HTML in your template (just for testing the approach), then you should be able to make it work with the equivalent Thymeleaf in the same template. – andrewJames Jan 11 '23 at 14:29
  • (Thymeleaf may not even be relevant, unless you want to make the file name a variable.) – andrewJames Jan 11 '23 at 14:35

1 Answers1

0

If you are adding the image to an email, the src must be a URL. This means that the image must be accessible from the outside.

jordiburgos
  • 5,964
  • 4
  • 46
  • 80