0

Is it possible to surpress img not found log message from html image tag in Angular 5.

I try to do:

  <img [src]="default_url+'_'+id+'.png'" [alt]="default_url+'dummy.svg'"  onerror="this.src=this.alt;return null;">

So showing the user image by id and if there is no image i would like to replace it with the dummy.svg.

This is working but delivers error (404 if dummy replace the main image) on console log. Which I would like to surpress.

Thanks!

shortQuestion
  • 473
  • 2
  • 16

1 Answers1

1

I'm not sure you can prevent the error to be shown in the console if the image url is not right, but you might try with a try-catch.

The responses on this thread my help you: Eliminate 404 url error in console?

Alemndra
  • 26
  • 6
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Mukesh Kumar Aug 14 '18 at 08:01