Handle missing movie posters
This commit is contained in:
parent
11b7c08722
commit
d51f56fc60
@ -32,17 +32,32 @@ function MoviePosters(props) {
|
||||
);
|
||||
}
|
||||
|
||||
function MoviePoster(props) {
|
||||
const imgUrl = '/img/movies/' + props.data.imdb_id +'.jpg';
|
||||
const selected = props.selected ? ' thumbnail-selected' : '';
|
||||
const imgClass = 'thumbnail' + selected;
|
||||
return (
|
||||
<div className="col-xs-12 col-md-3">
|
||||
<a className={imgClass}>
|
||||
<img src={imgUrl} onClick={props.onClick}/>
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
class MoviePoster extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
src: `/img/movies/${this.props.data.imdb_id}.jpg`,
|
||||
}
|
||||
this.handleError = this.handleError.bind(this);
|
||||
}
|
||||
handleError() {
|
||||
this.setState({ src: '/img/noimage.png' });
|
||||
}
|
||||
render() {
|
||||
const selected = this.props.selected ? ' thumbnail-selected' : '';
|
||||
const imgClass = 'thumbnail' + selected;
|
||||
return (
|
||||
<div className="col-xs-12 col-md-3">
|
||||
<a className={imgClass}>
|
||||
<img
|
||||
src={this.state.src}
|
||||
onClick={this.props.onClick}
|
||||
onError={this.handleError}
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function MovieDetails(props) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user