mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FEATURE: new twitter_summary_large_image_url setting
This commit is contained in:
parent
d46084d328
commit
332cc2bb95
3 changed files with 18 additions and 5 deletions
|
@ -142,8 +142,9 @@ module ApplicationHelper
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
opts[:url] ||= "#{Discourse.base_url_no_prefix}#{request.fullpath}"
|
opts[:url] ||= "#{Discourse.base_url_no_prefix}#{request.fullpath}"
|
||||||
|
|
||||||
if opts[:image].blank? && SiteSetting.default_opengraph_image_url.present?
|
if opts[:image].blank? && (SiteSetting.default_opengraph_image_url.present? || SiteSetting.twitter_summary_large_image_url.present?)
|
||||||
opts[:image] = SiteSetting.default_opengraph_image_url
|
opts[:twitter_summary_large_image] = SiteSetting.twitter_summary_large_image_url if SiteSetting.twitter_summary_large_image_url.present?
|
||||||
|
opts[:image] = SiteSetting.default_opengraph_image_url.present? ? SiteSetting.default_opengraph_image_url : SiteSetting.twitter_summary_large_image_url
|
||||||
elsif opts[:image].blank? && SiteSetting.apple_touch_icon_url.present?
|
elsif opts[:image].blank? && SiteSetting.apple_touch_icon_url.present?
|
||||||
opts[:image] = SiteSetting.apple_touch_icon_url
|
opts[:image] = SiteSetting.apple_touch_icon_url
|
||||||
end
|
end
|
||||||
|
@ -156,12 +157,22 @@ module ApplicationHelper
|
||||||
opts[:image] = "#{Discourse.base_url}#{opts[:image]}"
|
opts[:image] = "#{Discourse.base_url}#{opts[:image]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add opengraph tags
|
# Add opengraph & twitter tags
|
||||||
result = []
|
result = []
|
||||||
result << tag(:meta, property: 'og:site_name', content: SiteSetting.title)
|
result << tag(:meta, property: 'og:site_name', content: SiteSetting.title)
|
||||||
result << tag(:meta, name: 'twitter:card', content: "summary")
|
|
||||||
|
|
||||||
[:url, :title, :description, :image].each do |property|
|
if opts[:twitter_summary_large_image].present?
|
||||||
|
result << tag(:meta, name: 'twitter:card', content: "summary_large_image")
|
||||||
|
result << tag(:meta, name: "twitter:image", content: opts[:twitter_summary_large_image])
|
||||||
|
elsif opts[:image].present?
|
||||||
|
result << tag(:meta, name: 'twitter:card', content: "summary")
|
||||||
|
result << tag(:meta, name: "twitter:image", content: opts[:image])
|
||||||
|
else
|
||||||
|
result << tag(:meta, name: 'twitter:card', content: "summary")
|
||||||
|
end
|
||||||
|
result << tag(:meta, property: "og:image", content: opts[:image]) if opts[:image].present?
|
||||||
|
|
||||||
|
[:url, :title, :description].each do |property|
|
||||||
if opts[property].present?
|
if opts[property].present?
|
||||||
escape = (property != :image)
|
escape = (property != :image)
|
||||||
result << tag(:meta, { property: "og:#{property}", content: opts[property] }, nil, escape)
|
result << tag(:meta, { property: "og:#{property}", content: opts[property] }, nil, escape)
|
||||||
|
|
|
@ -1086,6 +1086,7 @@ en:
|
||||||
external_system_avatars_url: "URL of the external system avatars service. Allowed substitutions are {username} {first_letter} {color} {size}"
|
external_system_avatars_url: "URL of the external system avatars service. Allowed substitutions are {username} {first_letter} {color} {size}"
|
||||||
|
|
||||||
default_opengraph_image_url: "URL of the default opengraph image."
|
default_opengraph_image_url: "URL of the default opengraph image."
|
||||||
|
twitter_summary_large_image_url: "URL of the default Twitter summary card image (should be at least 280px in width, and at least 150px in height)."
|
||||||
|
|
||||||
allow_all_attachments_for_group_messages: "Allow all email attachments for group messages."
|
allow_all_attachments_for_group_messages: "Allow all email attachments for group messages."
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ required:
|
||||||
default: '/images/default-favicon.ico'
|
default: '/images/default-favicon.ico'
|
||||||
apple_touch_icon_url: '/images/default-apple-touch-icon.png'
|
apple_touch_icon_url: '/images/default-apple-touch-icon.png'
|
||||||
default_opengraph_image_url: ''
|
default_opengraph_image_url: ''
|
||||||
|
twitter_summary_large_image_url: ''
|
||||||
exclude_rel_nofollow_domains:
|
exclude_rel_nofollow_domains:
|
||||||
default: ''
|
default: ''
|
||||||
type: list
|
type: list
|
||||||
|
|
Loading…
Reference in a new issue