Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow alt-text length to be customisable #2737

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => ({
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/media_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/serializers/rest/v1/instance_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def configuration
},

media_attachments: {
max_characters: MediaAttachment::MAX_DESCRIPTION_LENGTH,
supported_mime_types: MediaAttachment.supported_mime_types,
image_size_limit: MediaAttachment::IMAGE_LIMIT,
image_matrix_limit: Attachmentable::MAX_MATRIX_LIMIT,
Expand Down