|
|
@ -6,7 +6,7 @@ import IconButton from './icon_button'; |
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; |
|
|
|
import { isIOS } from '../is_mobile'; |
|
|
|
import classNames from 'classnames'; |
|
|
|
import { autoPlayGif, displayMedia, useBlurhash } from '../initial_state'; |
|
|
|
import { autoPlayGif, cropImages, displayMedia, useBlurhash } from '../initial_state'; |
|
|
|
import { decode } from 'blurhash'; |
|
|
|
|
|
|
|
const messages = defineMessages({ |
|
|
@ -281,7 +281,7 @@ class MediaGallery extends React.PureComponent { |
|
|
|
} |
|
|
|
|
|
|
|
handleRef = (node) => { |
|
|
|
if (node /*&& this.isStandaloneEligible()*/) { |
|
|
|
if (node) { |
|
|
|
// offsetWidth triggers a layout, so only calculate when we need to
|
|
|
|
if (this.props.cacheWidth) this.props.cacheWidth(node.offsetWidth); |
|
|
|
|
|
|
@ -291,13 +291,13 @@ class MediaGallery extends React.PureComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
isStandaloneEligible() { |
|
|
|
const { media, standalone } = this.props; |
|
|
|
return standalone && media.size === 1 && media.getIn([0, 'meta', 'small', 'aspect']); |
|
|
|
isFullSizeEligible() { |
|
|
|
const { media } = this.props; |
|
|
|
return media.size === 1 && media.getIn([0, 'meta', 'small', 'aspect']); |
|
|
|
} |
|
|
|
|
|
|
|
render () { |
|
|
|
const { media, intl, sensitive, height, defaultWidth } = this.props; |
|
|
|
const { media, intl, sensitive, height, defaultWidth, standalone } = this.props; |
|
|
|
const { visible } = this.state; |
|
|
|
|
|
|
|
const width = this.state.width || defaultWidth; |
|
|
@ -306,7 +306,7 @@ class MediaGallery extends React.PureComponent { |
|
|
|
|
|
|
|
const style = {}; |
|
|
|
|
|
|
|
if (this.isStandaloneEligible()) { |
|
|
|
if (this.isFullSizeEligible() && (standalone || !cropImages)) { |
|
|
|
if (width) { |
|
|
|
style.height = width / this.props.media.getIn([0, 'meta', 'small', 'aspect']); |
|
|
|
} |
|
|
@ -319,7 +319,7 @@ class MediaGallery extends React.PureComponent { |
|
|
|
const size = media.take(4).size; |
|
|
|
const uncached = media.every(attachment => attachment.get('type') === 'unknown'); |
|
|
|
|
|
|
|
if (this.isStandaloneEligible()) { |
|
|
|
if (standalone && this.isFullSizeEligible()) { |
|
|
|
children = <Item standalone onClick={this.handleClick} attachment={media.get(0)} displayWidth={width} visible={visible} />; |
|
|
|
} else { |
|
|
|
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} index={i} size={size} displayWidth={width} visible={visible || uncached} />); |
|
|
|