What would be the correct way to build a srcset
-attribute with Thymeleaf
using the standart url syntax @{/...}
?
Example:
<img th:src="@{/i/1000.jpg}" srcset="/i/1500.jpg 1500w, /i/2000.jpg 2000w" />
Nevermind, it was easier than expected and logical at the same time:
<img
th:src="@{/i/1000.jpg}"
th:attr="srcset=@{/i/1500.jpg} + ' 1500w, ' + @{/i/2000.jpg} + ' 2000w'"
/>
The correct way for building of srcset attribute in thymeleaf is as follows:
<img th:attr="srcset=|@{/img/image1x.png} 1x, @{/img/image2x.png} 2x, @{/img/image3x.png} 3x|" th:src="@{/img/image1x.png}" alt="My image description text" />