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

45 lines
1.3 KiB
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
import type { Node } from 'react';
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
children?: Node,
2018-03-26 23:32:43 +02:00
};
const className = 'media__thumb';
class CardMedia extends React.PureComponent<Props> {
2017-07-14 01:18:28 +02:00
render() {
const { thumbnail, children } = this.props;
2017-07-14 01:18:28 +02:00
// Disabling temporarily to see if people complain
// if (thumbnail && thumbnail.endsWith('gif')) {
// return <FreezeframeWrapper src={thumbnail} className={className} />;
// }
2019-11-13 18:50:45 +01:00
let url;
// @if TARGET='web'
// Pass image urls through a compression proxy
2020-01-15 00:03:49 +01:00
url = thumbnail || Placeholder;
// url = thumbnail
// ? 'https://ext.thumbnails.lbry.com/400x,q55/' +
// // The image server will redirect if we don't remove the double slashes after http(s)
// thumbnail.replace('https://', 'https:/').replace('http://', 'http:/')
// : Placeholder;
2019-11-13 18:50:45 +01:00
// @endif
// @if TARGET='app'
url = thumbnail || Placeholder;
// @endif
return (
<div style={{ backgroundImage: `url('${url.replace(/'/g, "\\'")}')` }} className={className}>
{children}
</div>
);
2017-07-14 01:18:28 +02:00
}
}
export default CardMedia;