|
|
@ -36,6 +36,7 @@ class Item extends React.PureComponent {
|
|
|
|
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
static propTypes = {
|
|
|
|
attachment: ImmutablePropTypes.map.isRequired,
|
|
|
|
attachment: ImmutablePropTypes.map.isRequired,
|
|
|
|
|
|
|
|
lang: PropTypes.string,
|
|
|
|
standalone: PropTypes.bool,
|
|
|
|
standalone: PropTypes.bool,
|
|
|
|
index: PropTypes.number.isRequired,
|
|
|
|
index: PropTypes.number.isRequired,
|
|
|
|
size: PropTypes.number.isRequired,
|
|
|
|
size: PropTypes.number.isRequired,
|
|
|
@ -98,7 +99,7 @@ class Item extends React.PureComponent {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
render () {
|
|
|
|
const { attachment, index, size, standalone, letterbox, displayWidth, visible } = this.props;
|
|
|
|
const { attachment, lang, index, size, standalone, letterbox, displayWidth, visible } = this.props;
|
|
|
|
|
|
|
|
|
|
|
|
let width = 50;
|
|
|
|
let width = 50;
|
|
|
|
let height = 100;
|
|
|
|
let height = 100;
|
|
|
@ -154,7 +155,7 @@ class Item extends React.PureComponent {
|
|
|
|
if (attachment.get('type') === 'unknown') {
|
|
|
|
if (attachment.get('type') === 'unknown') {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className={classNames('media-gallery__item', { standalone })} key={attachment.get('id')} style={{ left: left, top: top, right: right, bottom: bottom, width: `${width}%`, height: `${height}%` }}>
|
|
|
|
<div className={classNames('media-gallery__item', { standalone })} key={attachment.get('id')} style={{ left: left, top: top, right: right, bottom: bottom, width: `${width}%`, height: `${height}%` }}>
|
|
|
|
<a className='media-gallery__item-thumbnail' href={attachment.get('remote_url') || attachment.get('url')} style={{ cursor: 'pointer' }} title={attachment.get('description')} target='_blank' rel='noopener noreferrer'>
|
|
|
|
<a className='media-gallery__item-thumbnail' href={attachment.get('remote_url') || attachment.get('url')} style={{ cursor: 'pointer' }} title={attachment.get('description')} lang={lang} target='_blank' rel='noopener noreferrer'>
|
|
|
|
<Blurhash
|
|
|
|
<Blurhash
|
|
|
|
hash={attachment.get('blurhash')}
|
|
|
|
hash={attachment.get('blurhash')}
|
|
|
|
className='media-gallery__preview'
|
|
|
|
className='media-gallery__preview'
|
|
|
@ -195,6 +196,7 @@ class Item extends React.PureComponent {
|
|
|
|
sizes={sizes}
|
|
|
|
sizes={sizes}
|
|
|
|
alt={attachment.get('description')}
|
|
|
|
alt={attachment.get('description')}
|
|
|
|
title={attachment.get('description')}
|
|
|
|
title={attachment.get('description')}
|
|
|
|
|
|
|
|
lang={lang}
|
|
|
|
style={{ objectPosition: letterbox ? null : `${x}% ${y}%` }}
|
|
|
|
style={{ objectPosition: letterbox ? null : `${x}% ${y}%` }}
|
|
|
|
onLoad={this.handleImageLoad}
|
|
|
|
onLoad={this.handleImageLoad}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
@ -209,6 +211,7 @@ class Item extends React.PureComponent {
|
|
|
|
className={`media-gallery__item-gifv-thumbnail${letterbox ? ' letterbox' : ''}`}
|
|
|
|
className={`media-gallery__item-gifv-thumbnail${letterbox ? ' letterbox' : ''}`}
|
|
|
|
aria-label={attachment.get('description')}
|
|
|
|
aria-label={attachment.get('description')}
|
|
|
|
title={attachment.get('description')}
|
|
|
|
title={attachment.get('description')}
|
|
|
|
|
|
|
|
lang={lang}
|
|
|
|
role='application'
|
|
|
|
role='application'
|
|
|
|
src={attachment.get('url')}
|
|
|
|
src={attachment.get('url')}
|
|
|
|
onClick={this.handleClick}
|
|
|
|
onClick={this.handleClick}
|
|
|
@ -251,6 +254,7 @@ class MediaGallery extends React.PureComponent {
|
|
|
|
fullwidth: PropTypes.bool,
|
|
|
|
fullwidth: PropTypes.bool,
|
|
|
|
hidden: PropTypes.bool,
|
|
|
|
hidden: PropTypes.bool,
|
|
|
|
media: ImmutablePropTypes.list.isRequired,
|
|
|
|
media: ImmutablePropTypes.list.isRequired,
|
|
|
|
|
|
|
|
lang: PropTypes.string,
|
|
|
|
size: PropTypes.object,
|
|
|
|
size: PropTypes.object,
|
|
|
|
onOpenMedia: PropTypes.func.isRequired,
|
|
|
|
onOpenMedia: PropTypes.func.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
@ -342,7 +346,7 @@ class MediaGallery extends React.PureComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
render () {
|
|
|
|
const { media, intl, sensitive, letterbox, fullwidth, defaultWidth, autoplay } = this.props;
|
|
|
|
const { media, lang, intl, sensitive, letterbox, fullwidth, defaultWidth, autoplay } = this.props;
|
|
|
|
const { visible } = this.state;
|
|
|
|
const { visible } = this.state;
|
|
|
|
const size = media.take(4).size;
|
|
|
|
const size = media.take(4).size;
|
|
|
|
const uncached = media.every(attachment => attachment.get('type') === 'unknown');
|
|
|
|
const uncached = media.every(attachment => attachment.get('type') === 'unknown');
|
|
|
@ -364,9 +368,9 @@ class MediaGallery extends React.PureComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.isStandaloneEligible()) {
|
|
|
|
if (this.isStandaloneEligible()) {
|
|
|
|
children = <Item standalone autoplay={autoplay} onClick={this.handleClick} attachment={media.get(0)} displayWidth={width} visible={visible} />;
|
|
|
|
children = <Item standalone autoplay={autoplay} onClick={this.handleClick} attachment={media.get(0)} lang={lang} displayWidth={width} visible={visible} />;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} autoplay={autoplay} onClick={this.handleClick} attachment={attachment} index={i} size={size} letterbox={letterbox} displayWidth={width} visible={visible || uncached} />);
|
|
|
|
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} autoplay={autoplay} onClick={this.handleClick} attachment={attachment} index={i} lang={lang} size={size} letterbox={letterbox} displayWidth={width} visible={visible || uncached} />);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (uncached) {
|
|
|
|
if (uncached) {
|
|
|
|