diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d0e70b6b0df..9504f22a04a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -150,11 +150,15 @@ module ApplicationHelper end # Use the correct scheme for open graph image - if opts[:image].present? && opts[:image].start_with?("//") - uri = URI(Discourse.base_url) - opts[:image] = "#{uri.scheme}:#{opts[:image]}" - elsif opts[:image].present? && opts[:image].start_with?("/uploads/") - opts[:image] = "#{Discourse.base_url}#{opts[:image]}" + if opts[:image].present? + if opts[:image].start_with?("//") + uri = URI(Discourse.base_url) + opts[:image] = "#{uri.scheme}:#{opts[:image]}" + elsif opts[:image].start_with?("/uploads/") + opts[:image] = "#{Discourse.base_url}#{opts[:image]}" + elsif GlobalSetting.relative_url_root && opts[:image].start_with?(GlobalSetting.relative_url_root) + opts[:image] = "#{Discourse.base_url_no_prefix}#{opts[:image]}" + end end # Add opengraph & twitter tags