Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit 52c4e17

Browse files
dogelover911dogelover911
and
dogelover911
authored
Add width and height to attachments in ActivityPub (mastodon#16245)
Co-authored-by: dogelover911 <dogelover911@localhost>
1 parent f09322f commit 52c4e17

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

app/serializers/activitypub/note_serializer.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class MediaAttachmentSerializer < ActivityPub::Serializer
170170

171171
attributes :type, :media_type, :url, :name, :blurhash
172172
attribute :focal_point, if: :focal_point?
173+
attribute :width, if: :width?
174+
attribute :height, if: :height?
173175

174176
has_one :icon, serializer: ActivityPub::ImageSerializer, if: :thumbnail?
175177

@@ -204,6 +206,22 @@ def icon
204206
def thumbnail?
205207
object.thumbnail.present?
206208
end
209+
210+
def width?
211+
object.file.meta&.dig('original', 'width').present?
212+
end
213+
214+
def height?
215+
object.file.meta&.dig('original', 'height').present?
216+
end
217+
218+
def width
219+
object.file.meta.dig('original', 'width')
220+
end
221+
222+
def height
223+
object.file.meta.dig('original', 'height')
224+
end
207225
end
208226

209227
class MentionSerializer < ActivityPub::Serializer

0 commit comments

Comments
 (0)