]> cat aescling's git repositories - mastodon.git/commitdiff
Improve JSON output for media attachments, generate :small preview for them
authorEugen Rochko <eugen@zeonfederated.com>
Mon, 5 Sep 2016 17:26:24 +0000 (19:26 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 5 Sep 2016 17:26:24 +0000 (19:26 +0200)
app/models/media_attachment.rb
app/views/api/statuses/show.rabl

index 835287ac9e818697e8c10b9e3f44ed9082139d72..1f51e3d13aebe57b568032b8429f5fe59def23c4 100644 (file)
@@ -2,7 +2,7 @@ class MediaAttachment < ApplicationRecord
   belongs_to :account, inverse_of: :media_attachments
   belongs_to :status,  inverse_of: :media_attachments
 
-  has_attached_file :file
+  has_attached_file :file, styles: { small: '510x680>' }
   validates_attachment_content_type :file, content_type: /\Aimage\/.*\z/
 
   validates :account, presence: true
index b8cf075fefc64730e73db63b05ba135a33e33ca8..21e054453c6592eeb5cb5000f17e751d71080ea2 100644 (file)
@@ -17,6 +17,9 @@ child :account do
   extends('api/accounts/show')
 end
 
-child :media_attachments do
+child :media_attachments, object_root: false do
+  attribute :remote_url
+
   node(:url) { |media| full_asset_url(media.file.url) }
+  node(:preview_url) { |media| full_asset_url(media.file.url(:small)) }
 end