A platform for community discussion. Free, open, simple.
FIX: use absolute URL for twitter:image tag
Arpit Jalan9919f16041da
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex cd3ed044537..82a5d5fbae6 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -210,17 +210,10 @@ module ApplicationHelperopts[:image] = SiteSetting.site_apple_touch_icon_urlend- # Use the correct scheme for open graph 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+ # Use the correct scheme for opengraph/twitter image+ opts[:image] = get_absolute_image_url(opts[:image]) if opts[:image].present?+ opts[:twitter_summary_large_image] =+ get_absolute_image_url(opts[:twitter_summary_large_image]) if opts[:twitter_summary_large_image].present?# Add opengraph & twitter tagsresult = []@@ -452,4 +445,17 @@ module ApplicationHelpersetup_dataend++ def get_absolute_image_url(link)+ absolute_url = link+ if link.start_with?("//")+ uri = URI(Discourse.base_url)+ absolute_url = "#{uri.scheme}:#{link}"+ elsif link.start_with?("/uploads/")+ absolute_url = "#{Discourse.base_url}#{link}"+ elsif GlobalSetting.relative_url_root && link.start_with?(GlobalSetting.relative_url_root)+ absolute_url = "#{Discourse.base_url_no_prefix}#{link}"+ end+ absolute_url+ endend