From 763ec735d00803376472ce40030cad2bbd37bcb5 Mon Sep 17 00:00:00 2001 From: MitarashiDango Date: Tue, 22 Oct 2024 01:43:57 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=A0=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E4=B8=8A=E3=81=AB=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E6=B7=BB=E4=BB=98=E3=83=A1=E3=83=87=E3=82=A3=E3=82=A2?= =?UTF-8?q?=E3=81=AE=E3=82=B5=E3=83=A0=E3=83=8D=E3=82=A4=E3=83=AB=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E3=82=92=E3=82=AF=E3=83=AD=E3=83=83=E3=83=97=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B=E8=A8=AD=E5=AE=9A=E9=A0=85=E7=9B=AE?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mastodon/components/media_gallery.jsx | 44 ++++++++++++------- app/javascript/mastodon/components/status.jsx | 6 +-- app/javascript/mastodon/initial_state.js | 2 + app/models/concerns/user/has_settings.rb | 4 ++ app/models/user_settings.rb | 1 + app/serializers/initial_state_serializer.rb | 1 + .../preferences/appearance/show.html.haml | 3 ++ config/locales/simple_form.en.yml | 2 + config/locales/simple_form.ja.yml | 2 + 9 files changed, 46 insertions(+), 19 deletions(-) diff --git a/app/javascript/mastodon/components/media_gallery.jsx b/app/javascript/mastodon/components/media_gallery.jsx index e059978442a131..cd8227c2b09515 100644 --- a/app/javascript/mastodon/components/media_gallery.jsx +++ b/app/javascript/mastodon/components/media_gallery.jsx @@ -14,7 +14,7 @@ import { AltTextBadge } from 'mastodon/components/alt_text_badge'; import { Blurhash } from 'mastodon/components/blurhash'; import { formatTime } from 'mastodon/features/video'; -import { autoPlayGif, displayMedia, useBlurhash } from '../initial_state'; +import { autoPlayGif, cropAttachmentThumbnailsOnTimeline, displayMedia, useBlurhash } from '../initial_state'; class Item extends PureComponent { @@ -57,7 +57,7 @@ class Item extends PureComponent { return this.props.autoplay || autoPlayGif; } - hoverToPlay () { + hoverToPlay() { const { attachment } = this.props; return !this.getAutoPlay() && ['gifv', 'video'].includes(attachment.get('type')); } @@ -81,12 +81,12 @@ class Item extends PureComponent { this.setState({ loaded: true }); }; - render () { + render() { const { attachment, lang, index, size, standalone, displayWidth, visible } = this.props; let badges = [], thumbnail; - let width = 50; + let width = 50; let height = 100; if (size === 1) { @@ -116,21 +116,21 @@ class Item extends PureComponent { ); } else if (attachment.get('type') === 'image') { - const previewUrl = attachment.get('preview_url'); + const previewUrl = attachment.get('preview_url'); const previewWidth = attachment.getIn(['meta', 'small', 'width']); - const originalUrl = attachment.get('url'); + const originalUrl = attachment.get('url'); const originalWidth = attachment.getIn(['meta', 'original', 'width']); const hasSize = typeof originalWidth === 'number' && typeof previewWidth === 'number'; const srcSet = hasSize ? `${originalUrl} ${originalWidth}w, ${previewUrl} ${previewWidth}w` : null; - const sizes = hasSize && (displayWidth > 0) ? `${displayWidth * (width / 100)}px` : null; + const sizes = hasSize && (displayWidth > 0) ? `${displayWidth * (width / 100)}px` : null; const focusX = attachment.getIn(['meta', 'focus', 'x']) || 0; const focusY = attachment.getIn(['meta', 'focus', 'y']) || 0; - const x = ((focusX / 2) + .5) * 100; - const y = ((focusY / -2) + .5) * 100; + const x = ((focusX / 2) + .5) * 100; + const y = ((focusY / -2) + .5) * 100; thumbnail = ( attachment.get('type') === 'unknown'); if (this.isFullSizeEligible()) { diff --git a/app/javascript/mastodon/components/status.jsx b/app/javascript/mastodon/components/status.jsx index e1ffc637bae713..c40860057a9ff1 100644 --- a/app/javascript/mastodon/components/status.jsx +++ b/app/javascript/mastodon/components/status.jsx @@ -24,7 +24,7 @@ import Card from '../features/status/components/card'; import Bundle from '../features/ui/components/bundle'; import { MediaGallery, Video, Audio } from '../features/ui/util/async-components'; import { SensitiveMediaContext } from '../features/ui/util/sensitive_media_context'; -import { displayMedia } from '../initial_state'; +import { cropAttachmentThumbnailsOnTimeline, displayMedia } from '../initial_state'; import AttachmentList from './attachment_list'; import { Avatar } from './avatar'; @@ -209,7 +209,7 @@ class Status extends ImmutablePureComponent { 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'])}`; + return cropAttachmentThumbnailsOnTimeline ? '16 / 9' : `${attachments.getIn([0, 'meta', 'original', 'width'])} / ${attachments.getIn([0, 'meta', 'original', 'height'])}`; } else if (attachments.getIn([0, 'type']) === 'audio') { return '16 / 9'; } else { @@ -513,7 +513,7 @@ class Status extends ImmutablePureComponent {