discourse/app/serializers/upload_serializer.rb
Régis Hanol f43c0a5d85 FIX: uploading an image as a site setting
When uploading an image as a site setting, we need to return the "raw" URL, otherwise
when saving the site setting, the upload won't be looked up properly.

Follow-up-to: f11363d446
2020-07-03 13:23:10 +02:00

22 lines
558 B
Ruby

# frozen_string_literal: true
class UploadSerializer < ApplicationSerializer
attributes :id,
:url,
:original_filename,
:filesize,
:width,
:height,
:thumbnail_width,
:thumbnail_height,
:extension,
:short_url,
:short_path,
:retain_hours,
:human_filesize
def url
object.for_site_setting ? object.url : UrlHelper.cook_url(object.url, secure: SiteSetting.secure_media? && object.secure)
end
end