FIX: uploading an existing image as a site setting

The previous fix (f43c0a5d85) wasn't working for images that were already uploaded.
The "metadata" (eg. 'for_*' and 'secure' attributes) were not added to existing uploads.

Also used 'Upload.get_from_url' is the admin/site_setting controller to properly retrieve
an upload from its URL.

Fixed the Upload::URL_REGEX to use the \h (hexadecimal) for the SHA

Follow-up-to: f43c0a5d85
This commit is contained in:
Régis Hanol
2020-07-03 19:16:54 +02:00
parent 4c1e690e32
commit 48b4ed41f5
4 changed files with 22 additions and 22 deletions

View File

@@ -17,7 +17,7 @@ class Admin::SiteSettingsController < Admin::AdminController
raise_access_hidden_setting(id)
if SiteSetting.type_supervisor.get_type(id) == :upload
value = Upload.find_by(url: value) || ''
value = Upload.get_from_url(value) || ""
end
update_existing_users = params[:updateExistingUsers].present?