Skip to content

Commit

Permalink
Merge 250a223 into 5c8bc51
Browse files Browse the repository at this point in the history
  • Loading branch information
mertkahyaoglu committed Mar 20, 2020
2 parents 5c8bc51 + 250a223 commit 1220f4c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/FilePreview.js
Expand Up @@ -34,11 +34,20 @@ export default class FilePreview extends Component {
}
}

get isImageFile() {
const {
file: { type, extname },
} = this.props;
if (type === 'directory') {
return false;
}

return /png|jpg|gif|jpeg|svg|ico/i.test(extname.substring(1));
}

render() {
const { onClick, file, splat } = this.props;
const extension = file.extname.substring(1);
const image = /png|jpg|gif|jpeg|svg|ico/i.test(extension);
const node = image ? (
const node = this.isImageFile ? (
<img src={file.http_url} alt={file.relative_path} />
) : (
<div>
Expand Down

0 comments on commit 1220f4c

Please sign in to comment.