From 6b1f1a33b43c4739e3c2273ac718b90add73e67f Mon Sep 17 00:00:00 2001 From: artpi Date: Wed, 27 Jan 2016 15:53:16 -0500 Subject: [PATCH] Gravatar fallback for offline OFFLINE: Gravatar fallback for offline OFFLINE: gravatar fallback: add leading slash OFFLINE gravatar: ternary fallback OFFLINE gravatar fallback: change to default icon --- client/components/gravatar/index.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/components/gravatar/index.jsx b/client/components/gravatar/index.jsx index 1e0565c67f00..703f41e85199 100644 --- a/client/components/gravatar/index.jsx +++ b/client/components/gravatar/index.jsx @@ -27,6 +27,12 @@ module.exports = React.createClass( { }; }, + getInitialState: function() { + return { + failedToLoad: false + } + }, + _getResizedImageURL: function( imageURL ) { var parsedURL, query; @@ -44,18 +50,24 @@ module.exports = React.createClass( { return url.format( parsedURL ); }, + onError: function() { + this.setState( { failedToLoad: true } ); + }, + render: function() { const size = this.props.size; if ( ! this.props.user ) { return ; + } else if ( this.state.failedToLoad ) { + return ; } const alt = this.props.alt || this.props.user.display_name; const avatarURL = this._getResizedImageURL( safeImageURL( this.props.user.avatar_URL ) ); return ( - { + { ); }