Here, We are working on web application then facing issue in image loading and error, so we need to set alternate or default image in the web application.
Many ways to set default image in the web page :
Set default image using CSS
img
{
background-image:url('default.png');
}
Set default image using javascript or jquery
<script>
$(document).ready(function()
{
$(".backup_picture").error(function(){
$(this).attr('src', 'default.png');
});
});
</script>
<img class='backup_picture' src='./images/nonexistent_image_file.png' />
Set default image in img tag when getting error
<img src="imagenotfound.gif" alt="Image not found" onError="this.src='default.gif';" />
0 Comment(s)