2
<img src="${url.resourcesPath}/images/logo.png" />

Problem: Above code path is working in template.ftl but same thing not working in email template.

In email template we have try with various options but baseUrl and rootUrl also not coming there.

olibiaz
  • 2,551
  • 4
  • 29
  • 31
  • a shame that keycloak still does not address this issue. I've seen threads from 5 years ago and keycloak version 4.0.0, now we're sitting at 14.0.0 – leachim Jul 08 '21 at 10:39
  • https://stackoverflow.com/questions/57692616/keycloak-add-company-logo-to-the-reset-password-email -- is this what you are looking for? – user353829 Aug 30 '21 at 22:46

1 Answers1

1

We can use ${url.resourcesCommonPath}

  1. File location (keycloak/themes/lnsw/email/theme.properties). Add the following line to the theme.properties file

    basePath=http://localhost:5005

    phoneIcon=/img/alpha124.png

eg. enter image description here

  1. Create a folder structure for image resources as follows (keycloak/themes/keycloak/common/resources/img/alpha124.png) enter image description here

  2. Use the following code in the .ftl template file enter image description here

Sachin Nikumbh
  • 911
  • 11
  • 11
  • There is no ${url} in scope of email-test, at least at Keycloak 19.0.2 your approach does not work. If you take look on FreeMarkerEmailTemplateProvider.java you will not find "url" for sendSmtpTestEmail but for some reason "url" is set for almost all others emails. So had better not to use {url} in scope of common template.ftl and email-test. – Sergey Zubatkin Sep 30 '22 at 06:50
  • how about if we have a react or vue format file that be handled by webpack. the path of images don't work when generating .ftl format – amir tbi Feb 21 '23 at 12:25