Topic: mdb-card-img If image fails, replace with default image
hi i'm using this card-img to display an image coming from a database, but if the link fails, how can I default card-img to display my default image from assets?
Damian Gemza staff answered 5 years ago
Dear @rodrigae
I don't know, how you're implementing the image in your card - via mdb-card-image
component, or you're making card image overlay with style="background-image"
on mdb-card
component.
But in those two cases, you have to write some typescript code to check, if the image from the server is loaded. If it's loaded, pass to the mdb-card
component the image from the server. If it's not loaded, pass the default one from assets. That shouldn't be hard to implement.
Best Regards,
Damian
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: 8.0.0
- Device: Windows
- Browser: Chrome
- OS: 10
- Provided sample code: No
- Provided link: No