Add og:image:width and og:image:height.
This commit is contained in:
parent
51c3b1b747
commit
947c68669d
|
@ -753,7 +753,21 @@ class AnnouncementsController < ApplicationController
|
||||||
|
|
||||||
request = OrbitHelper.request
|
request = OrbitHelper.request
|
||||||
meta_desc = announcement.subtitle.nil? || announcement.subtitle == "" ? announcement.text.to_s[0..200] : announcement.subtitle
|
meta_desc = announcement.subtitle.nil? || announcement.subtitle == "" ? announcement.text.to_s[0..200] : announcement.subtitle
|
||||||
OrbitHelper.render_meta_tags([{"property" => "og:title", "content" => announcement.title},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:image", "content" => "#{request.base_url}#{announcement.image.url}"},{"property" => "og:type", "content" => "Article"}])
|
metas = [{"property" => "og:title", "content" => announcement.title},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:type", "content" => "Article"}]
|
||||||
|
if announcement.image.present?
|
||||||
|
metas << {"property" => "og:image", "content" => URI.join(request.base_url, URI.encode(announcement.image.url)).to_s}
|
||||||
|
img_src_path = announcement.image.path
|
||||||
|
if File.exist?(img_src_path)
|
||||||
|
image = MiniMagick::Image.open(img_src_path)
|
||||||
|
if image[:width]
|
||||||
|
metas << {"property" => "og:image:width", "content" => image[:width].to_s}
|
||||||
|
end
|
||||||
|
if image[:height]
|
||||||
|
metas << {"property" => "og:image:height", "content" => image[:height].to_s}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
OrbitHelper.render_meta_tags(metas)
|
||||||
|
|
||||||
subtitle_ann = nil
|
subtitle_ann = nil
|
||||||
img_src = nil
|
img_src = nil
|
||||||
|
@ -876,7 +890,18 @@ class AnnouncementsController < ApplicationController
|
||||||
meta_desc = ""
|
meta_desc = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
OrbitHelper.render_meta_tags([{"property" => "og:title", "content" => announcement["title_translations"][locale]},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:image", "content" => announcement["image"]["original"]},{"property" => "og:type", "content" => "Article"}])
|
metas = [{"property" => "og:title", "content" => announcement["title_translations"][locale]},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:type", "content" => "Article"}]
|
||||||
|
if announcement["image"]["original"].present?
|
||||||
|
image = announcement["image"]
|
||||||
|
metas << {"property" => "og:image", "content" => image["original"]}
|
||||||
|
if image["width"]
|
||||||
|
metas << {"property" => "og:image:width", "content" => image["width"].to_s}
|
||||||
|
end
|
||||||
|
if image["height"]
|
||||||
|
metas << {"property" => "og:image:height", "content" => image["height"].to_s}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
OrbitHelper.render_meta_tags(metas)
|
||||||
|
|
||||||
datetime = announcement["postdate"] ? DateTime.parse(announcement["postdate"]) : nil
|
datetime = announcement["postdate"] ? DateTime.parse(announcement["postdate"]) : nil
|
||||||
|
|
||||||
|
|
|
@ -406,9 +406,16 @@ class Bulletin
|
||||||
a["image_description_translations"] = self.image_description_translations
|
a["image_description_translations"] = self.image_description_translations
|
||||||
a["image"] = {}
|
a["image"] = {}
|
||||||
a["display_img"] = self.display_img
|
a["display_img"] = self.display_img
|
||||||
|
if self.image.present?
|
||||||
a["image"]["original"] = ("#{base_url}" + self.image.url rescue "")
|
a["image"]["original"] = ("#{base_url}" + self.image.url rescue "")
|
||||||
a["image"]["thumb"] = ("#{base_url}" + self.image.thumb.url rescue "")
|
a["image"]["thumb"] = ("#{base_url}" + self.image.thumb.url rescue "")
|
||||||
a["image"]["mobile"] = ("#{base_url}" + self.image.mobile.url rescue "")
|
a["image"]["mobile"] = ("#{base_url}" + self.image.mobile.url rescue "")
|
||||||
|
image = MiniMagick::Image.open(self.image.path) rescue nil
|
||||||
|
if image
|
||||||
|
a["image"]["width"] = image[:width]
|
||||||
|
a["image"]["height"] = image[:height]
|
||||||
|
end
|
||||||
|
end
|
||||||
a["tags"] = []
|
a["tags"] = []
|
||||||
a["category"] = {}
|
a["category"] = {}
|
||||||
a["author"] = author
|
a["author"] = author
|
||||||
|
|
Loading…
Reference in New Issue