mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 21:21:19 +08:00
FEATURE: fall back to apple_touch_icon_url if default_opengraph_image_url is not present
This commit is contained in:
@ -142,14 +142,18 @@ module ApplicationHelper
|
|||||||
opts ||= {}
|
opts ||= {}
|
||||||
opts[:url] ||= "#{Discourse.base_url_no_prefix}#{request.fullpath}"
|
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?("//")
|
if opts[:image].present? && opts[:image].start_with?("//")
|
||||||
uri = URI(Discourse.base_url)
|
uri = URI(Discourse.base_url)
|
||||||
opts[:image] = "#{uri.scheme}:#{opts[:image]}"
|
opts[:image] = "#{uri.scheme}:#{opts[:image]}"
|
||||||
elsif opts[:image].present? && opts[:image].start_with?("/uploads/")
|
elsif opts[:image].present? && opts[:image].start_with?("/uploads/")
|
||||||
opts[:image] = "#{Discourse.base_url}#{opts[:image]}"
|
opts[:image] = "#{Discourse.base_url}#{opts[:image]}"
|
||||||
elsif SiteSetting.default_opengraph_image_url.present?
|
|
||||||
opts[:image] = SiteSetting.default_opengraph_image_url
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add opengraph tags
|
# Add opengraph tags
|
||||||
|
Reference in New Issue
Block a user