Horje

Tips (Total 1)


# Tips-1) How to set Multiple Image if First Image is error

Here is simple way to set multiple Image if First Image is error.

This function is called Fallback.

Image Fallback Function HTML

See the Example.

You can add multiple image using 'https://cdn-icons-png.flaticon.com/128/6912/6912971.png' into the code.

index.html
Example: HTML
<script>
function incrementFallbackSrc(img, srcs) {
    if (typeof img.fallbackSrcIndex === 'undefined') img.fallbackSrcIndex = 0;
    img.src = srcs[img.fallbackSrcIndex++];
}    
</script>

<img
src="https://cdn-icons-png.flaticon.com/128/8067/8067997.png"
onerror="javascript: incrementFallbackSrc(this, ['https://cdn-icons-png.flaticon.com/128/8067/8067999.png',
'https://cdn-icons-png.flaticon.com/128/6912/6912971.png'
])">

Output should be: