Skip to content

Commit 43a2632

Browse files
authored
Merge pull request #763 from technologic-technologic/feature/760
fix: ensure fallback image is available in the view model -> Issue #760
2 parents faeed61 + fb2afaf commit 43a2632

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/main/java/com/josdem/vetlog/controller/AdoptionController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class AdoptionController {
5050
@Value("${imageBucket}")
5151
private String imageBucket;
5252

53+
@Value("${defaultImage}")
54+
private String defaultImage;
55+
5356
@InitBinder("adoptionCommand")
5457
private void initBinder(WebDataBinder binder) {
5558
binder.addValidators(adoptionValidator);
@@ -74,6 +77,7 @@ public ModelAndView save(@Valid AdoptionCommand adoptionCommand, BindingResult b
7477
var modelAndView = new ModelAndView("pet/listForAdoption");
7578
modelAndView.addObject("pets", pets);
7679
modelAndView.addObject("gcpImageUrl", gcpUrl + imageBucket + "/");
80+
modelAndView.addObject("defaultImage", defaultImage);
7781
return modelAndView;
7882
}
7983

src/main/resources/templates/pet/listForAdoption.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
</a>
6161
</div>
6262
</div>
63+
<div th:if="${pet.images.isEmpty()}" align="center">
64+
<img style="width:320px;height:300px;" th:attr="src=@{${gcpImageUrl} + ${defaultImage}}"/>
65+
</div>
6366
<div th:data-testid="adoptionContainer" class="caption">
6467
<h3 th:data-testid="petName" th:text="${pet.name}"></h3>
6568
<p th:data-testid="petBirhdate" th:text="${@dateFormatter.formatToDate(pet.birthDate, #locale)}"/>

0 commit comments

Comments
 (0)