mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-09 11:55:09 +01:00
Increase remote media count to 16
* Remove remote media count limit * Show >4 images in a grid * Fix gallery for <4 media * Don't use weirdly wide images in media gallery Also support cols > 4 (size > 16) * Use 3/2 ratio * Port to glitch
This commit is contained in:
parent
0a1b5df202
commit
5d686826dd
@ -16,6 +16,14 @@ import { formatTime } from 'mastodon/features/video';
|
||||
|
||||
import { autoPlayGif, displayMedia, useBlurhash } from '../initial_state';
|
||||
|
||||
const colCount = function(size) {
|
||||
return Math.max(Math.floor(Math.sqrt(size)), 2);
|
||||
};
|
||||
|
||||
const rowCount = function(size) {
|
||||
return Math.ceil(size / colCount(size));
|
||||
};
|
||||
|
||||
class Item extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
@ -87,14 +95,18 @@ class Item extends PureComponent {
|
||||
let badges = [], thumbnail;
|
||||
|
||||
let width = 50;
|
||||
let height = 100;
|
||||
let height = 50;
|
||||
|
||||
if (size === 1) {
|
||||
const cols = colCount(size);
|
||||
const remaining = (-size % cols + cols) % cols;
|
||||
const largeCount = Math.floor(remaining / 3); // width=2, height=2
|
||||
const mediumCount = remaining % 3; // height=2
|
||||
|
||||
if (size === 1 || index < largeCount) {
|
||||
width = 100;
|
||||
}
|
||||
|
||||
if (size === 4 || (size === 3 && index > 0)) {
|
||||
height = 50;
|
||||
height = 100;
|
||||
} else if (size === 2 || index < largeCount + mediumCount) {
|
||||
height = 100;
|
||||
}
|
||||
|
||||
const description = attachment.getIn(['translation', 'description']) || attachment.get('description');
|
||||
@ -302,6 +314,11 @@ class MediaGallery extends PureComponent {
|
||||
if (this.isFullSizeEligible()) {
|
||||
style.aspectRatio = `${this.props.media.getIn([0, 'meta', 'small', 'aspect'])}`;
|
||||
} else {
|
||||
const cols = colCount(media.size);
|
||||
const rows = rowCount(media.size);
|
||||
style.gridTemplateColumns = `repeat(${cols}, 1fr)`;
|
||||
style.gridTemplateRows = `repeat(${rows}, 1fr)`;
|
||||
|
||||
style.aspectRatio = '3 / 2';
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||
def process_status_params
|
||||
@status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url, object: @object)
|
||||
|
||||
attachment_ids = process_attachments.take(Status::MEDIA_ATTACHMENTS_LIMIT).map(&:id)
|
||||
attachment_ids = process_attachments.take(Status::REMOTE_MEDIA_ATTACHMENTS_LIMIT).map(&:id)
|
||||
|
||||
@params = {
|
||||
uri: @status_parser.uri,
|
||||
@ -244,7 +244,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||
as_array(@object['attachment']).each do |attachment|
|
||||
media_attachment_parser = ActivityPub::Parser::MediaAttachmentParser.new(attachment)
|
||||
|
||||
next if media_attachment_parser.remote_url.blank? || media_attachments.size >= Status::MEDIA_ATTACHMENTS_LIMIT
|
||||
next if media_attachment_parser.remote_url.blank? || media_attachments.size >= Status::REMOTE_MEDIA_ATTACHMENTS_LIMIT
|
||||
|
||||
begin
|
||||
media_attachment = MediaAttachment.create(
|
||||
|
@ -40,6 +40,7 @@ class Status < ApplicationRecord
|
||||
include Status::ThreadingConcern
|
||||
|
||||
MEDIA_ATTACHMENTS_LIMIT = 4
|
||||
REMOTE_MEDIA_ATTACHMENTS_LIMIT = 16
|
||||
|
||||
rate_limit by: :account, family: :statuses
|
||||
|
||||
|
@ -75,7 +75,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||
as_array(@json['attachment']).each do |attachment|
|
||||
media_attachment_parser = ActivityPub::Parser::MediaAttachmentParser.new(attachment)
|
||||
|
||||
next if media_attachment_parser.remote_url.blank? || @next_media_attachments.size > Status::MEDIA_ATTACHMENTS_LIMIT
|
||||
next if media_attachment_parser.remote_url.blank? || @next_media_attachments.size > Status::REMOTE_MEDIA_ATTACHMENTS_LIMIT
|
||||
|
||||
begin
|
||||
media_attachment = previous_media_attachments.find { |previous_media_attachment| previous_media_attachment.remote_url == media_attachment_parser.remote_url }
|
||||
|
Loading…
Reference in New Issue
Block a user