mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-11-10 05:34:44 +00:00
default img if img fails to load
This commit is contained in:
parent
1db54e9f7a
commit
52bc6a27a4
@ -138,12 +138,11 @@ class ReviewCard extends HTMLElement {
|
||||
let mealImg = document.createElement("img");
|
||||
mealImg.setAttribute("id", "a-mealImg");
|
||||
mealImg.setAttribute("alt","Meal Photo Corrupted");
|
||||
if(data["mealImg"] != ""){
|
||||
mealImg.setAttribute("src",data["mealImg"]);
|
||||
}
|
||||
else{
|
||||
mealImg.setAttribute("src",data["mealImg"]);
|
||||
mealImg.addEventListener("error", function(e) {
|
||||
mealImg.setAttribute("src", "./assets/images/icons/plate_with_cutlery.png");
|
||||
}
|
||||
e.onerror = null;
|
||||
});
|
||||
|
||||
//meal name setup
|
||||
let mealLabel = document.createElement("label");
|
||||
|
@ -16,12 +16,11 @@ function setupInfo(){
|
||||
|
||||
//meal image
|
||||
let mealImg = document.getElementById("d-mealImg");
|
||||
if(currReview["mealImg"] != ""){
|
||||
mealImg.setAttribute("src",currReview["mealImg"]);
|
||||
}
|
||||
else{
|
||||
mealImg.setAttribute("src",currReview["mealImg"]);
|
||||
mealImg.addEventListener("error", function(e) {
|
||||
mealImg.setAttribute("src", "./assets/images/icons/plate_with_cutlery.png");
|
||||
}
|
||||
e.onerror = null;
|
||||
});
|
||||
|
||||
//meal name
|
||||
let mealLabel = document.getElementById("d-mealName");
|
||||
@ -78,7 +77,6 @@ function setupUpdate(){
|
||||
|
||||
//Set value of each input element to current's values
|
||||
document.getElementById("mealImg").defaultValue = currReview["mealImg"];
|
||||
document.getElementById("imgAlt").defaultValue = currReview["imgAlt"];
|
||||
document.getElementById("mealName").defaultValue = currReview["mealName"];
|
||||
document.getElementById("comments").textContent = currReview["comments"];
|
||||
document.getElementById("s" + `${currReview["rating"]}`).checked = true;
|
||||
|
Loading…
Reference in New Issue
Block a user