Allow alt-text length to be customisable

pull/2737/head
nullishamy 2024-06-09 15:23:30 +01:00
parent 4c55a6ee73
commit f123fc4a2b
No known key found for this signature in database
3 changed files with 5 additions and 3 deletions

View File

@ -50,6 +50,7 @@ const mapStateToProps = (state, { id }) => ({
focusY: state.getIn(['compose', 'media_modal', 'focusY']),
dirty: state.getIn(['compose', 'media_modal', 'dirty']),
is_changing_upload: state.getIn(['compose', 'is_changing_upload']),
maxChars: state.getIn(['server', 'server', 'configuration', 'media_attachments', 'max_characters'], 1_500),
});
const mapDispatchToProps = (dispatch, { id }) => ({
@ -279,7 +280,7 @@ class FocalPointModal extends ImmutablePureComponent {
};
render () {
const { media, intl, account, onClose, isUploadingThumbnail, description, lang, focusX, focusY, dirty, is_changing_upload } = this.props;
const { media, intl, account, onClose, isUploadingThumbnail, description, lang, focusX, focusY, dirty, is_changing_upload, maxChars } = this.props;
const { dragging, detecting, progress, ocrStatus } = this.state;
const x = (focusX / 2) + .5;
const y = (focusY / -2) + .5;
@ -375,7 +376,7 @@ class FocalPointModal extends ImmutablePureComponent {
>
<FormattedMessage id='upload_modal.detect_text' defaultMessage='Detect text from picture' />
</button>
<CharacterCounter max={1500} text={detecting ? '' : description} />
<CharacterCounter max={maxChars} text={detecting ? '' : description} />
</div>
<Button

View File

@ -37,7 +37,7 @@ class MediaAttachment < ApplicationRecord
enum :type, { image: 0, gifv: 1, video: 2, unknown: 3, audio: 4 }
enum :processing, { queued: 0, in_progress: 1, complete: 2, failed: 3 }, prefix: true
MAX_DESCRIPTION_LENGTH = 1_500
MAX_DESCRIPTION_LENGTH = (ENV['MAX_ATTACHMENT_DESCRIPTION'] || 1_500).to_i
IMAGE_LIMIT = (ENV['MAX_IMAGE_SIZE'] || 16.megabytes).to_i
VIDEO_LIMIT = (ENV['MAX_VIDEO_SIZE'] || 99.megabytes).to_i

View File

@ -84,6 +84,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
media_attachments: {
supported_mime_types: MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES + MediaAttachment::AUDIO_MIME_TYPES,
max_characters: MediaAttachment::MAX_DESCRIPTION_LENGTH,
image_size_limit: MediaAttachment::IMAGE_LIMIT,
image_matrix_limit: Attachmentable::MAX_MATRIX_LIMIT,
video_size_limit: MediaAttachment::VIDEO_LIMIT,