-1

Here if user upload a image it will show the uploaded image. But in other case if user forget to upload images or images is not uploaded then instead of showing this iconenter image description here

I want to show only empty squares. So please let me know if it is possible. or How can we achieve this

Inayat Kazi
  • 113
  • 1
  • 9
  • Does this answer your question? [How to hide image broken Icon using only CSS/HTML?](https://stackoverflow.com/questions/22051573/how-to-hide-image-broken-icon-using-only-css-html) – Tom Dec 28 '21 at 16:09
  • it is not at all showing any thing. In my case if images is not uploaded only square box has to display – Inayat Kazi Dec 28 '21 at 16:12
  • https://stackoverflow.com/a/6622396/14141568 This answer seemed to work for me – ramya Dec 28 '21 at 16:14
  • Thanks @ramya Your solutions it seems it is working. But in my case we have given path "src="http://127.0.0.1:5000/media/" – Inayat Kazi Dec 28 '21 at 16:26

2 Answers2

1

Did you try onerror with the image tag?

<img src="media.jpg" onerror="this.onerror=null; this.src='https://toppng.com/uploads/preview/and-blank-effect-transparent-11546868080xgtiz6hxid.png'"/>

something like this.

ramya
  • 33
  • 1
  • 8
0

you can make sure the url you are loading from is not null if it is instead of creating an image tag create a div that is styled as a box