Remove 16:9 cropping from web UI (#26132)
This commit is contained in:
		@@ -12,7 +12,7 @@ import { debounce } from 'lodash';
 | 
			
		||||
 | 
			
		||||
import { Blurhash } from 'mastodon/components/blurhash';
 | 
			
		||||
 | 
			
		||||
import { autoPlayGif, cropImages, displayMedia, useBlurhash } from '../initial_state';
 | 
			
		||||
import { autoPlayGif, displayMedia, useBlurhash } from '../initial_state';
 | 
			
		||||
 | 
			
		||||
import { IconButton } from './icon_button';
 | 
			
		||||
 | 
			
		||||
@@ -209,7 +209,6 @@ class MediaGallery extends PureComponent {
 | 
			
		||||
 | 
			
		||||
  static propTypes = {
 | 
			
		||||
    sensitive: PropTypes.bool,
 | 
			
		||||
    standalone: PropTypes.bool,
 | 
			
		||||
    media: ImmutablePropTypes.list.isRequired,
 | 
			
		||||
    lang: PropTypes.string,
 | 
			
		||||
    size: PropTypes.object,
 | 
			
		||||
@@ -223,10 +222,6 @@ class MediaGallery extends PureComponent {
 | 
			
		||||
    onToggleVisibility: PropTypes.func,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  static defaultProps = {
 | 
			
		||||
    standalone: false,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  state = {
 | 
			
		||||
    visible: this.props.visible !== undefined ? this.props.visible : (displayMedia !== 'hide_all' && !this.props.sensitive || displayMedia === 'show_all'),
 | 
			
		||||
    width: this.props.defaultWidth,
 | 
			
		||||
@@ -295,7 +290,7 @@ class MediaGallery extends PureComponent {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  render () {
 | 
			
		||||
    const { media, lang, intl, sensitive, defaultWidth, standalone, autoplay } = this.props;
 | 
			
		||||
    const { media, lang, intl, sensitive, defaultWidth, autoplay } = this.props;
 | 
			
		||||
    const { visible } = this.state;
 | 
			
		||||
    const width = this.state.width || defaultWidth;
 | 
			
		||||
 | 
			
		||||
@@ -303,16 +298,16 @@ class MediaGallery extends PureComponent {
 | 
			
		||||
 | 
			
		||||
    const style = {};
 | 
			
		||||
 | 
			
		||||
    if (this.isFullSizeEligible() && (standalone || !cropImages)) {
 | 
			
		||||
    if (this.isFullSizeEligible()) {
 | 
			
		||||
      style.aspectRatio = `${this.props.media.getIn([0, 'meta', 'small', 'aspect'])}`;
 | 
			
		||||
    } else {
 | 
			
		||||
      style.aspectRatio = '16 / 9';
 | 
			
		||||
      style.aspectRatio = '3 / 2';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const size     = media.take(4).size;
 | 
			
		||||
    const uncached = media.every(attachment => attachment.get('type') === 'unknown');
 | 
			
		||||
 | 
			
		||||
    if (standalone && this.isFullSizeEligible()) {
 | 
			
		||||
    if (this.isFullSizeEligible()) {
 | 
			
		||||
      children = <Item standalone autoplay={autoplay} onClick={this.handleClick} attachment={media.get(0)} lang={lang} displayWidth={width} visible={visible} />;
 | 
			
		||||
    } else {
 | 
			
		||||
      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} displayWidth={width} visible={visible || uncached} />);
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ class PictureInPicturePlaceholder extends PureComponent {
 | 
			
		||||
 | 
			
		||||
  static propTypes = {
 | 
			
		||||
    dispatch: PropTypes.func.isRequired,
 | 
			
		||||
    aspectRatio: PropTypes.string,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  handleClick = () => {
 | 
			
		||||
@@ -20,8 +21,10 @@ class PictureInPicturePlaceholder extends PureComponent {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  render () {
 | 
			
		||||
    const { aspectRatio } = this.props;
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
      <div className='picture-in-picture-placeholder' role='button' tabIndex={0} onClick={this.handleClick}>
 | 
			
		||||
      <div className='picture-in-picture-placeholder' style={{ aspectRatio }} role='button' tabIndex={0} onClick={this.handleClick}>
 | 
			
		||||
        <Icon id='window-restore' />
 | 
			
		||||
        <FormattedMessage id='picture_in_picture.restore' defaultMessage='Put it back' />
 | 
			
		||||
      </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@ import Bundle from '../features/ui/components/bundle';
 | 
			
		||||
import { MediaGallery, Video, Audio } from '../features/ui/util/async-components';
 | 
			
		||||
import { displayMedia } from '../initial_state';
 | 
			
		||||
 | 
			
		||||
import AttachmentList from './attachment_list';
 | 
			
		||||
import { Avatar } from './avatar';
 | 
			
		||||
import { AvatarOverlay } from './avatar_overlay';
 | 
			
		||||
import { DisplayName } from './display_name';
 | 
			
		||||
@@ -191,17 +190,35 @@ class Status extends ImmutablePureComponent {
 | 
			
		||||
    this.props.onTranslate(this._properStatus());
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  renderLoadingMediaGallery () {
 | 
			
		||||
    return <div className='media-gallery' style={{ height: '110px' }} />;
 | 
			
		||||
  getAttachmentAspectRatio () {
 | 
			
		||||
    const attachments = this._properStatus().get('media_attachments');
 | 
			
		||||
 | 
			
		||||
    if (attachments.getIn([0, 'type']) === 'video') {
 | 
			
		||||
      return `${attachments.getIn([0, 'meta', 'original', 'width'])} / ${attachments.getIn([0, 'meta', 'original', 'height'])}`;
 | 
			
		||||
    } else if (attachments.getIn([0, 'type']) === 'audio') {
 | 
			
		||||
      return '16 / 9';
 | 
			
		||||
    } else {
 | 
			
		||||
      return (attachments.size === 1 && attachments.getIn([0, 'meta', 'small', 'aspect'])) ? attachments.getIn([0, 'meta', 'small', 'aspect']) : '3 / 2'
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  renderLoadingVideoPlayer () {
 | 
			
		||||
    return <div className='video-player' style={{ height: '110px' }} />;
 | 
			
		||||
  }
 | 
			
		||||
  renderLoadingMediaGallery = () => {
 | 
			
		||||
    return (
 | 
			
		||||
      <div className='media-gallery' style={{ aspectRatio: this.getAttachmentAspectRatio() }} />
 | 
			
		||||
    );
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  renderLoadingAudioPlayer () {
 | 
			
		||||
    return <div className='audio-player' style={{ height: '110px' }} />;
 | 
			
		||||
  }
 | 
			
		||||
  renderLoadingVideoPlayer = () => {
 | 
			
		||||
    return (
 | 
			
		||||
      <div className='video-player' style={{ aspectRatio: this.getAttachmentAspectRatio() }} />
 | 
			
		||||
    );
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  renderLoadingAudioPlayer = () => {
 | 
			
		||||
    return (
 | 
			
		||||
      <div className='audio-player' style={{ aspectRatio: this.getAttachmentAspectRatio() }} />
 | 
			
		||||
    );
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  handleOpenVideo = (options) => {
 | 
			
		||||
    const status = this._properStatus();
 | 
			
		||||
@@ -426,18 +443,11 @@ class Status extends ImmutablePureComponent {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (pictureInPicture.get('inUse')) {
 | 
			
		||||
      media = <PictureInPicturePlaceholder />;
 | 
			
		||||
      media = <PictureInPicturePlaceholder aspectRatio={this.getAttachmentAspectRatio()} />;
 | 
			
		||||
    } else if (status.get('media_attachments').size > 0) {
 | 
			
		||||
      const language = status.getIn(['translation', 'language']) || status.get('language');
 | 
			
		||||
 | 
			
		||||
      if (this.props.muted) {
 | 
			
		||||
        media = (
 | 
			
		||||
          <AttachmentList
 | 
			
		||||
            compact
 | 
			
		||||
            media={status.get('media_attachments')}
 | 
			
		||||
          />
 | 
			
		||||
        );
 | 
			
		||||
      } else if (status.getIn(['media_attachments', 0, 'type']) === 'audio') {
 | 
			
		||||
      if (status.getIn(['media_attachments', 0, 'type']) === 'audio') {
 | 
			
		||||
        const attachment = status.getIn(['media_attachments', 0]);
 | 
			
		||||
        const description = attachment.getIn(['translation', 'description']) || attachment.get('description');
 | 
			
		||||
 | 
			
		||||
@@ -475,11 +485,11 @@ class Status extends ImmutablePureComponent {
 | 
			
		||||
              <Component
 | 
			
		||||
                preview={attachment.get('preview_url')}
 | 
			
		||||
                frameRate={attachment.getIn(['meta', 'original', 'frame_rate'])}
 | 
			
		||||
                aspectRatio={`${attachment.getIn(['meta', 'original', 'width'])} / ${attachment.getIn(['meta', 'original', 'height'])}`}
 | 
			
		||||
                blurhash={attachment.get('blurhash')}
 | 
			
		||||
                src={attachment.get('url')}
 | 
			
		||||
                alt={description}
 | 
			
		||||
                lang={language}
 | 
			
		||||
                inline
 | 
			
		||||
                sensitive={status.get('sensitive')}
 | 
			
		||||
                onOpenVideo={this.handleOpenVideo}
 | 
			
		||||
                deployPictureInPicture={pictureInPicture.get('available') ? this.handleDeployPictureInPicture : undefined}
 | 
			
		||||
@@ -508,7 +518,7 @@ class Status extends ImmutablePureComponent {
 | 
			
		||||
          </Bundle>
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    } else if (status.get('spoiler_text').length === 0 && status.get('card') && !this.props.muted) {
 | 
			
		||||
    } else if (status.get('spoiler_text').length === 0 && status.get('card')) {
 | 
			
		||||
      media = (
 | 
			
		||||
        <Card
 | 
			
		||||
          onOpenMedia={this.handleOpenMedia}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user