diff --git a/app/models/theme.rb b/app/models/theme.rb index c177d47154c..7eef07af10a 100644 --- a/app/models/theme.rb +++ b/app/models/theme.rb @@ -714,17 +714,21 @@ class Theme < ActiveRecord::Base def build_theme_uploads_hash hash = {} - upload_fields.each do |field| - hash[field.name] = Discourse.store.cdn_url(field.upload.url) if field.upload&.url - end + upload_fields + .includes(:javascript_cache, :upload) + .each do |field| + hash[field.name] = Discourse.store.cdn_url(field.upload.url) if field.upload&.url + end hash end def build_local_theme_uploads_hash hash = {} - upload_fields.each do |field| - hash[field.name] = field.javascript_cache.local_url if field.javascript_cache - end + upload_fields + .includes(:javascript_cache, :upload) + .each do |field| + hash[field.name] = field.javascript_cache.local_url if field.javascript_cache + end hash end @@ -843,6 +847,8 @@ class Theme < ActiveRecord::Base if upload = field.upload url = upload_cdn_path(upload.url) contents << "$#{field.name}: unquote(\"#{url}\");" + else + contents << "$#{field.name}: unquote(\"\");" end else contents << to_scss_variable(field.name, field.value)