Fixed the bug if image is not found

- Added a Not Available image, which will be used as the image for movie if poster_path is null or image is not available.
- To see it working, search "Interstellar".
pull/122/head
Maitray Bhardwaj 3 years ago
parent cd228d507d
commit 4073a137f0

@ -6,6 +6,8 @@ const main = document.getElementById('main')
const form = document.getElementById('form')
const search = document.getElementById('search')
const naImg = 'https://feb.kuleuven.be/drc/LEER/visiting-scholars-1/image-not-available.jpg/image'
// Get initial movies
getMovies(API_URL)
@ -25,8 +27,10 @@ function showMovies(movies) {
const movieEl = document.createElement('div')
movieEl.classList.add('movie')
const imgSrc = poster_path == null ? naImg : IMG_PATH + poster_path
movieEl.innerHTML = `
<img src="${IMG_PATH + poster_path}" alt="${title}">
<img src="${imgSrc}" alt="${title}">
<div class="movie-info">
<h3>${title}</h3>
<span class="${getClassByRate(vote_average)}">${vote_average}</span>

Loading…
Cancel
Save