Join and normalize og:image url using Addressable
Avoids failing on urls that are not strictly rfc2396 URIs.
This commit is contained in:
parent
84aa7f455a
commit
c03649355a
4 changed files with 27 additions and 1 deletions
|
@ -1,10 +1,12 @@
|
|||
module OpenGraphHelper
|
||||
require "addressable/uri"
|
||||
|
||||
def opengraph_tags(title = nil, og_image = nil)
|
||||
tags = {
|
||||
"og:site_name" => t("layouts.project_name.title"),
|
||||
"og:title" => title || t("layouts.project_name.title"),
|
||||
"og:type" => "website",
|
||||
"og:image" => og_image ? URI.join(root_url, og_image) : image_url("osm_logo_256.png"),
|
||||
"og:image" => og_image ? Addressable::URI.join(root_url, og_image).normalize : image_url("osm_logo_256.png"),
|
||||
"og:url" => url_for(:only_path => false),
|
||||
"og:description" => t("layouts.intro_text")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue