From f6bd114b5e45a16627eb79f08aacb4e4af0c3814 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Mon, 22 Aug 2016 14:58:46 +0530 Subject: [PATCH] FEATURE: fall back to apple_touch_icon_url if default_opengraph_image_url is not present --- app/helpers/application_helper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 59d6d91e89e..7a9e06c799f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -142,14 +142,18 @@ module ApplicationHelper opts ||= {} opts[:url] ||= "#{Discourse.base_url_no_prefix}#{request.fullpath}" - # Use the correct scheme for open graph + if opts[:image].blank? && SiteSetting.default_opengraph_image_url.present? + opts[:image] = SiteSetting.default_opengraph_image_url + elsif opts[:image].blank? && SiteSetting.apple_touch_icon_url.present? + opts[:image] = SiteSetting.apple_touch_icon_url + 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]}" - elsif SiteSetting.default_opengraph_image_url.present? - opts[:image] = SiteSetting.default_opengraph_image_url end # Add opengraph tags