1
0

media_attachment_serializer.rb 451 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. class REST::MediaAttachmentSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. attributes :id, :type, :url, :preview_url,
  5. :remote_url, :text_url, :meta
  6. def url
  7. full_asset_url(object.file.url(:original))
  8. end
  9. def preview_url
  10. full_asset_url(object.file.url(:small))
  11. end
  12. def text_url
  13. object.local? ? medium_url(object) : nil
  14. end
  15. def meta
  16. object.file.meta
  17. end
  18. end