Skip to content

Replace broken images in sponsor list #1846

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

Merged
merged 7 commits into from
Feb 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/components/Support/Support.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import Backers from './support-backers.json';
import Additional from './support-additional.js';
import SmallIcon from '../../assets/icon-square-small-slack.png';
import './Support.scss';

const SUPPORTERS = [ ...Backers ];
Expand Down Expand Up @@ -100,11 +101,11 @@ export default class Support extends React.Component {
title={ `$${formatMoney(supporter.totalDonations / 100)} by ${supporter.name || supporter.slug}` }
target="_blank"
href={ supporter.website || `https://opencollective.com/${supporter.slug}` }>
{ supporter.avatar ? <img
{<img
className={ `support__${rank}-avatar` }
src={ supporter.avatar }
alt={ supporter.name || supporter.slug ? `${supporter.name || supporter.slug}'s avatar` : 'avatar' } /> :
<span className={ `support__${rank}-avatar` }>{supporter.name || supporter.slug}</span> }
src={ supporter.avatar || SmallIcon }
alt={ supporter.name || supporter.slug ? `${supporter.name || supporter.slug}'s avatar` : 'avatar' }
onError={ this._handleImgError } />}
{ rank === 'backer' ? <figure className="support__outline" /> : null }
</a>
))
Expand All @@ -118,4 +119,14 @@ export default class Support extends React.Component {
</div>
);
}

/**
* Handle images that aren't found
*
* @param {object} e - React synthetic event
*/
_handleImgError(e) {
const imgNode = e.target;
imgNode.src = SmallIcon;
}
}