-2

On our website, we have a classifieds section.

If a user does not add an image in their Classifieds listing in the Classifieds section, how can I hide the broken image icon and show my own default image instead.

See issue on my website

Let me know.

Thanks.

Sociopath
  • 13,068
  • 19
  • 47
  • 75
  • 2
    Possible duplicate of [Can I hide broken images?](https://stackoverflow.com/questions/3545132/can-i-hide-broken-images) – Ashton Sep 12 '18 at 01:10
  • Also possible duplicate of [Inputting a default image in case the src attribute of an html is not valid?](https://stackoverflow.com/a/980910/784648) which provides some HTML only solutions to this. – A. J. Parr Sep 12 '18 at 06:03
  • https://stackoverflow.com/questions/3235913/how-to-silently-hide-image-not-found-icon-when-src-source-image-is-not-found – 7060965 Sep 12 '18 at 06:28

1 Answers1

-1

You need to create a validation on your code to check if the image is missing on your condition create a default image if there is no image uploaded.

if(!empty($image['imageuploaded'])){
   /** display the uploaded image 
}else{
 /** Display default
}