How to show alternate image if source image is not found?
I Am using amp-img tag. I won't implement above functionality. Can you please help?
@evivz To clarify: Are you asking for a way to show a fallback (backup alternate image) in the case that the src specified by amp-img is not found (i.e. 404)?
Is there some reason why it cannot be reliably known whether the image is available?
I am serving images from third party services and many times they are dead. Before I could update their replacement in my server many people visit my website. I want to serve them alternate image temporarily.
@rudygalfi @evivz @sriramkrish85 We can consider fallback element for image in this case. But it can't be an infinite thing. I.e it'd only be one attempt -> one fallback -> that's it.
<amp-img src="...">
<amp-img fallback src="default.png"></amp-img>
</amp-img>
It doesn't only have to be image as a fallback - it could be an SVG or even a basic DIV with text.
If this is agreeable, we can explore this option.
Yes this will work.
Any updates by when this feature/request will be added?
i'll take over this one. should be able to start on it late tomorrow or thursday.
Thanks, @erwinmombay . Just for posterity: for the complete solution this issue will be blocked on #2261.
I am not able to get this fallback.. how should i use this fallback feature?
<amp-img src = "<%= post.ProfileImage %>" width = "40" height = "40" placeholder> <amp-img fallback src = "/images/broker-profile.jpg" width = "40" height = "40"> </amp-img> </amp-img>
@kishanj918 so it is currently in opt in canary and a user will have to turn on "dev channel" in cdn.ampproject.org/experiments.html do try it out if it solves your problem. if there are no issues it will be released to production by Thursday next week
@erwinmombay That worked. Thanks