Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show alternate image if source image is not found? #2335

Closed
evivz opened this issue Feb 29, 2016 · 10 comments
Closed

How to show alternate image if source image is not found? #2335

evivz opened this issue Feb 29, 2016 · 10 comments

Comments

@evivz
Copy link

evivz commented Feb 29, 2016

I Am using amp-img tag. I won't implement above functionality. Can you please help?

@rudygalfi
Copy link
Contributor

@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?

@evivz
Copy link
Author

evivz commented Feb 29, 2016

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.

@dvoytenko
Copy link
Contributor

@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.

@rudygalfi rudygalfi added this to the M2 milestone Mar 2, 2016
@rudygalfi rudygalfi modified the milestones: M2, Backlog Mar 4, 2016
@evivz
Copy link
Author

evivz commented Mar 7, 2016

Yes this will work.

@evivz
Copy link
Author

evivz commented Mar 8, 2016

Any updates by when this feature/request will be added?

@erwinmombay erwinmombay self-assigned this Mar 8, 2016
@erwinmombay
Copy link
Member

i'll take over this one. should be able to start on it late tomorrow or thursday.

@dvoytenko dvoytenko modified the milestones: Fixit - March 2016, Backlog Mar 8, 2016
@dvoytenko
Copy link
Contributor

Thanks, @erwinmombay . Just for posterity: for the complete solution this issue will be blocked on #2261.

@kishanj918
Copy link

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>

@erwinmombay
Copy link
Member

@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

@kishanj918
Copy link

@erwinmombay That worked. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants