2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
class UploadSerializer < ApplicationSerializer
|
2017-08-22 16:40:01 -04:00
|
|
|
attributes :id,
|
|
|
|
:url,
|
|
|
|
:original_filename,
|
|
|
|
:filesize,
|
|
|
|
:width,
|
|
|
|
:height,
|
2018-08-27 22:48:43 -04:00
|
|
|
:thumbnail_width,
|
|
|
|
:thumbnail_height,
|
2017-08-22 16:40:01 -04:00
|
|
|
:extension,
|
|
|
|
:short_url,
|
2020-04-14 19:19:59 -04:00
|
|
|
:short_path,
|
2019-02-20 21:13:37 -05:00
|
|
|
:retain_hours,
|
2022-09-20 05:28:17 -04:00
|
|
|
:human_filesize,
|
|
|
|
:dominant_color
|
2020-01-15 22:50:27 -05:00
|
|
|
|
2024-10-18 04:55:14 -04:00
|
|
|
has_one :thumbnail,
|
|
|
|
serializer: UploadThumbnailSerializer,
|
|
|
|
root: false,
|
|
|
|
embed: :object,
|
|
|
|
if: -> { SiteSetting.create_thumbnails && object.has_thumbnail? }
|
|
|
|
|
2020-01-15 22:50:27 -05:00
|
|
|
def url
|
2022-09-28 19:24:33 -04:00
|
|
|
if object.for_site_setting
|
|
|
|
object.url
|
2023-01-09 07:20:10 -05:00
|
|
|
else
|
2022-09-28 19:24:33 -04:00
|
|
|
UrlHelper.cook_url(object.url, secure: SiteSetting.secure_uploads? && object.secure)
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2020-01-15 22:50:27 -05:00
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|