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