Skip to content

Commit 56f2029

Browse files
BenLubarGargron
authored andcommitted
Improve image description user experience (mastodon#10036)
* Add image descriptions to searchable post content. * Allow multi-line image descriptions. * Request image descriptions in the same query as posts when creating the search index. (see mastodon#10036 (comment))
1 parent 1fcf385 commit 56f2029

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

app/chewy/statuses_index.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class StatusesIndex < Chewy::Index
3131
},
3232
}
3333

34-
define_type ::Status.unscoped.without_reblogs do
34+
define_type ::Status.unscoped.without_reblogs.includes(:media_attachments) do
3535
crutch :mentions do |collection|
3636
data = ::Mention.where(status_id: collection.map(&:id)).pluck(:status_id, :account_id)
3737
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
@@ -50,7 +50,7 @@ class StatusesIndex < Chewy::Index
5050
root date_detection: false do
5151
field :account_id, type: 'long'
5252

53-
field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].join("\n\n") } do
53+
field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].concat(status.media_attachments.map(&:description)).join("\n\n") } do
5454
field :stemmed, type: 'text', analyzer: 'content'
5555
end
5656

app/javascript/mastodon/features/compose/components/upload.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ class Upload extends ImmutablePureComponent {
108108
<label>
109109
<span style={{ display: 'none' }}>{intl.formatMessage(messages.description)}</span>
110110

111-
<input
111+
<textarea
112112
placeholder={intl.formatMessage(messages.description)}
113-
type='text'
114113
value={description}
115114
maxLength={420}
116115
onFocus={this.handleInputFocus}

app/javascript/styles/mastodon/components.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@
476476
opacity: 0;
477477
transition: opacity .1s ease;
478478

479-
input {
479+
textarea {
480480
background: transparent;
481481
color: $secondary-text-color;
482482
border: 0;

0 commit comments

Comments
 (0)