The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
700 B

  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. :description
  7. def id
  8. object.id.to_s
  9. end
  10. def url
  11. if object.needs_redownload?
  12. media_proxy_url(object.id, :original)
  13. else
  14. full_asset_url(object.file.url(:original))
  15. end
  16. end
  17. def preview_url
  18. if object.needs_redownload?
  19. media_proxy_url(object.id, :small)
  20. else
  21. full_asset_url(object.file.url(:small))
  22. end
  23. end
  24. def text_url
  25. object.local? ? medium_url(object) : nil
  26. end
  27. def meta
  28. object.file.meta
  29. end
  30. end