Hide Broken Img Link But Have An Alt

I am using a movie API to get images and I am trying to have an alt in case the image does not appear but I want the broken img icon to not show up either. There has to be a solution for that.

//this is my attempted solution the oneerror does not work and the broken img icon appears
<img key={movie.id} src={"https://image.tmdb.org/t/p/w185/" + movie.poster_path} alt="No image listed" onerror="this.style.display='none'" />

Okay I solved it rather quickly, I updated my css to include

img:before { 
  content: "Image is not listed";
  display: block;
  margin-bottom: 10px;

img:after { 
  content: "";
  display: block;
  font-size: 12px;

and I made my alt property in my img tag “”

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.