OS
Edition: Windows 10 Pro
Version: 21H1
Installed on: 2020-08-13
OS build: 19043.1237
Experience: Windows Feature Experience Pack 120.2212.3530.0
Eclipse STS
Version: 4.12.0.RELEASE
Build Id: 202109130635
Java
java version “11.0.12” 2021-07-20 LTS
Java™ SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)
Java HotSpot™ 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)
Spring Boot
spring-boot-starter-parent: 2.5.4
spring-boot-starter-thymeleaf: 2.5.4
thymeleaf-extras-java8time: 3.0.4.RELEASE
thymeleaf-extras-springsecurity5: 3.0.4.RELEASE
SonarLint
SonarLint for Eclipse: 6.1.0.36269 (ID: org.sonarlint.eclipse.feature.feature.group; provider: SonarSource)
For given IMG a hint is raised:
Add an “alt” attribute to this image.
<img
th:class="${ #lists.size( blogPostItem.photos ) == 1 ? 'Single' : 'Multiple' }"
th:src="${ '/img/' + photo.id + '/large' }"
th:onclick="TheVegCat.photo([[${ '/img/' + photo.id + '/full' }]]);"
th:alt="${ blogPostItem.name }"
th:title="${ blogPostItem.name }"
/>
Potential workaround
Put additional alt attribute not managed by Thymeleaf and hope Thymeleaf will override it with its own managed alt attribute:
<img
th:class="${ #lists.size( blogPostItem.photos ) == 1 ? 'Single' : 'Multiple' }"
th:src="${ '/img/' + photo.id + '/large' }"
th:onclick="TheVegCat.photo([[${ '/img/' + photo.id + '/full' }]]);"
alt="Dummy alt just to satisfy SonarLint"
th:alt="${ blogPostItem.name }"
th:title="${ blogPostItem.name }"
/>