lbry-desktop/ui/component/cardMedia/view.jsx

26 lines
718 B
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
import React from 'react';
import FreezeframeWrapper from './FreezeframeWrapper';
2019-03-05 05:46:57 +01:00
import Placeholder from './placeholder.png';
2017-07-14 01:18:28 +02:00
2018-03-26 23:32:43 +02:00
type Props = {
thumbnail: ?string, // externally sourced image
};
const className = 'media__thumb';
2018-03-26 23:32:43 +02:00
class CardMedia extends React.PureComponent<Props> {
2017-07-14 01:18:28 +02:00
render() {
const { thumbnail } = this.props;
2017-07-14 01:18:28 +02:00
if (thumbnail && thumbnail.endsWith('gif')) {
return <FreezeframeWrapper src={thumbnail} className={className} />;
}
const url = thumbnail ? 'https://ext.thumbnails.lbry.com/400x,q55/' + thumbnail : Placeholder;
return <div style={{ backgroundImage: `url('${url.replace(/'/g, "\\'")}')` }} className={className} />;
2017-07-14 01:18:28 +02:00
}
}
export default CardMedia;