-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add onError to img element #134
Comments
How about instead we just support a new |
If the The issue at the moment is that the 404 status code from gravatar is currently lost, because it is never captured. If that makes sense? I don't like filing issues with "It doesn't work for my particular use-case" ... but .... in my particular use-case, I want to render a custom avatar component if they don't have a gravatar account. So if their username is "cjke" it would display a "C" in a circle, if their username is "Kyle", it would show a "K" in a circle. So the fallback is a complete component, not just an image. So yes, if |
Ah gotcha — yeah that makes sense — a backup default component is way more flexible than a backup src. Cool, let's just go with your original proposal then. Someone could do what I was proposing with a simple |
Groovy I will get a PR together shortly. |
Added PR at #135 I've also updated the demo page to demonstrate a simple example of a fallback component. |
The PR is actually very useful.. Reopen? |
I need this specific thing, can we please make this happen? |
This which allows users to specify a fallback component, which is great for folks who do not want to fallback to a different image source. For example, users can have a "default profile" component that gets passed in as the `fallback` prop. # Related feature request: KyleAMathews#134
I have created a PR that provides this functionality: #146 |
Gravatar accepts a type of "404" - which, if the email is invalid, will return a
404
status code (instead of say retro or wavatar, etc).Currently though, there is no way to capture that and action via
react-gravatar
. It would be nice to be able to pass in a onError prop, and let it be mounted to the img element. This way, a parent component, could catch it, and render a more app relevant default image.Alternatively, a
defaultComponent
prop could be passed, that when a 404 is returned, thereact-gravatar
would render it instead.Happy to PR if this aligns with the projects goals
The text was updated successfully, but these errors were encountered: